Exemplo n.º 1
0
        //private int[] enabledLogLevels  = new int[] {2, 3, 4, 5};

        //private Dictionary<LogLevel, string[]> logFilters = new Dictionary<LogLevel, string[]>();

        public ToolkitLogProvider(IServiceScopeFactory services, IGlobalLogConfiguration globalLogCfg)
        {
            this.services     = services;
            this.globalLogCfg = globalLogCfg;
            LogEnvironment.RegisterLogTarget(this);
            timer = new Timer(DumpEvents, null, 10000, Timeout.Infinite);
        }
Exemplo n.º 2
0
 public CollectingLogger(ILogCollectorService collectorService, string category, IGlobalLogConfiguration configuration)
 {
     this.collectorService = collectorService;
     this.category         = category;
     this.configuration    = configuration;
 }
        public static void UpdateLoggingOptions(this IServiceProvider services)
        {
            IGlobalSettings <DbLoggingOptions> logSettings = services.GetService <IGlobalSettings <DbLoggingOptions> >();
            IGlobalLogConfiguration            target      = services.GetService <IGlobalLogConfiguration>();
            List <int> l   = new List <int>();
            var        opt = logSettings.Value;

            if (opt.LogEnabled)
            {
                if (opt.LogCritical)
                {
                    l.Add((int)LogLevel.Critical);
                }

                if (opt.LogDebug)
                {
                    l.Add((int)LogLevel.Debug);
                }

                if (opt.LogError)
                {
                    l.Add((int)LogLevel.Error);
                }

                if (opt.LogInformation)
                {
                    l.Add((int)LogLevel.Information);
                }

                if (opt.LogTrace)
                {
                    l.Add((int)LogLevel.Trace);
                }

                if (opt.LogWarning)
                {
                    l.Add((int)LogLevel.Warning);
                }

                if (opt.LogNone)
                {
                    l.Add((int)LogLevel.None);
                }
            }

            var filters = new Dictionary <LogLevel, string[]>();

            if (opt.LogEnabled)
            {
                if (opt.LogCritical && opt.CriticalFilters != null && opt.CriticalFilters.Length != 0)
                {
                    filters.Add(LogLevel.Critical, opt.CriticalFilters);
                }

                if (opt.LogDebug && opt.DebugFilters != null && opt.DebugFilters.Length != 0)
                {
                    filters.Add(LogLevel.Debug, opt.DebugFilters);
                }

                if (opt.LogError && opt.ErrorFilters != null && opt.ErrorFilters.Length != 0)
                {
                    filters.Add(LogLevel.Error, opt.ErrorFilters);
                }

                if (opt.LogInformation && opt.InformationFilters != null && opt.InformationFilters.Length != 0)
                {
                    filters.Add(LogLevel.Information, opt.InformationFilters);
                }

                if (opt.LogTrace && opt.TraceFilters != null && opt.TraceFilters.Length != 0)
                {
                    filters.Add(LogLevel.Trace, opt.TraceFilters);
                }

                if (opt.LogWarning && opt.WarningFilters != null && opt.WarningFilters.Length != 0)
                {
                    filters.Add(LogLevel.Warning, opt.WarningFilters);
                }
            }

            target.Configure(l.ToArray(), filters);
        }
 /// <summary>
 /// Initializes a new instance of the CollectingLoggerDecorator class
 /// </summary>
 /// <param name="provider"></param>
 public CollectingLoggerDecorator(IEnumerable <ILoggerProvider> providers, IGlobalLogConfiguration configuration)
 {
     this.configuration = configuration;
     myTopic            = typeof(TTopic).FullName;
     decoratedLoggers   = providers.Select(n => n.CreateLogger(myTopic)).ToArray();
 }
Exemplo n.º 5
0
 public ToolkitConsoleLogger(string categoryName, IGlobalLogConfiguration config)
 {
     this.categoryName = categoryName;
     this.config       = config;
 }
Exemplo n.º 6
0
 public ToolkitConsoleProvider(IGlobalLogConfiguration config)
 {
     this.config = config;
 }