Example #1
0
 protected LoggerProvider(LoggerSettings settings)
 {
     if (settings == null)
     {
         throw new ArgumentNullException(nameof(settings));
     }
     settings.ChangeToken?.RegisterChangeCallback(OnConfigurationReload, null);
 }
Example #2
0
 protected void ReloadLoggerOptions(LoggerSettings settings)
 {
     _includeScopes = settings.IncludeScopes;
     foreach (var logger in Loggers)
     {
         logger.Filter        = GetFilter(logger.Name, settings);
         logger.IncludeScopes = _includeScopes;
         logger.ApplySettings(settings);
     }
 }
Example #3
0
        private void OnConfigurationReload(object state)
        {
            LoggerSettings settings = null;

            try {
                // The settings object needs to change here, because the old one is probably holding on
                // to an old change token.
                settings = GetSettings(true);
            } catch (Exception ex) {
                //System.Console.WriteLine( $"Error while loading configuration changes.{Environment.NewLine}{ex}" );
            } finally {
                // The token will change each time it reloads, so we need to register again.
                settings?.ChangeToken?.RegisterChangeCallback(OnConfigurationReload, null);
            }
        }
Example #4
0
        private Func <string, LogLevel, bool> GetFilter(string name, LoggerSettings settings)
        {
            if (_filter != null)
            {
                return(_filter);
            }

            if (settings != null)
            {
                if (settings.TryGetSwitch(name, out LogLevel level))
                {
                    return(level.GetFilter());
                }
                return(settings.MinLevel.GetFilter());
            }

            return(LogLevelUtil.False);
        }
Example #5
0
 protected internal virtual void ApplySettings(LoggerSettings options)
 {
     _formater = null;
 }