public static bool EventsBelowCertainLevel(LogEvent logEvent, LoggerSourceContextLevelOverrides globalSwitches)
        {
            (LogEventLevel defaultLevel, System.Collections.Generic.KeyValuePair <System.Func <LogEvent, bool>, LogEventLevel>[] matchers) = globalSwitches.Current;

            for (int i = 0; i < matchers.Length; i++)
            {
                System.Collections.Generic.KeyValuePair <System.Func <LogEvent, bool>, LogEventLevel> filter = matchers[i];
                if (filter.Key(logEvent))
                {
                    return(logEvent.Level < filter.Value);
                }
            }

            return(logEvent.Level < defaultLevel);
        }
Beispiel #2
0
 public void Update(LoggerSourceContextLevelOverrides newSwitches)
 {
     Interlocked.Exchange(ref currentConfiguration, newSwitches.currentConfiguration);
 }
 public LoggerConfiguration Overrides(LoggerSourceContextLevelOverrides switches)
 {
     configuration.Filter.ByExcluding(e => EventsBelowCertainLevel(e, switches));
     return(configuration);
 }
 public ApplicationLoggerBuilder()
 {
     globalSwitches = new LoggerSourceContextLevelOverrides();
 }