protected LoggerProvider(LoggerSettings settings) { if (settings == null) { throw new ArgumentNullException(nameof(settings)); } settings.ChangeToken?.RegisterChangeCallback(OnConfigurationReload, null); }
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); } }
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); } }
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); }
protected internal virtual void ApplySettings(LoggerSettings options) { _formater = null; }