internal static void SetGlobalFilterNavMatcher(INamespaceNavigationMatcher matcher, string defaultLevel)
        {
            GlobalNavigationMatcher = matcher ?? throw new ArgumentNullException(nameof(matcher));

            lock (_sinkFilterNavMatcherLock) {
                if (_defaultLevel.ContainsKey("Global"))
                {
                    _defaultLevel["Global"] = LogEventLevelConverter.Convert(defaultLevel);
                }
                else
                {
                    _defaultLevel.Add("Global", LogEventLevelConverter.Convert(defaultLevel));
                }
            }
        }
        private void SetSelf(LoggingConfiguration configuration)
        {
            var settings = _loggingSettings as LoggingOptions ?? LoggingOptions.Defaults;

            if (configuration == null)
            {
                IncludeScopes = false;
                LogLevel      = new Dictionary <string, string> {
                    { "Default", "Information" }
                };
                Rendering = new RenderingConfiguration(settings.Rendering);
            }
            else
            {
                IncludeScopes = configuration.IncludeScopes;
                LogLevel      = configuration.LogLevel;
                Rendering     = new RenderingConfiguration(configuration.Rendering, settings.Rendering);
            }

            Aliases.MergeAndOverWrite(settings.InternalAliases, k => k, v => v.GetName());
            LogLevel.MergeAndOverWrite(settings.InternalNavigatorLogEventLevels, k => k, v => v.GetName());

            foreach (var item in LogLevel)
            {
                var nav = _namespaceNavigatorCache.Parse(item.Key, item.Value, out _);
                if (nav is EmptyNamespaceNavigationNode)
                {
                    continue;
                }
                if (!_namespaceFilterNavRoots.Contains(nav))
                {
                    _namespaceFilterNavRoots.Add(nav);
                }
            }

            NavigationFilterProcessor.SetGlobalFilterNavMatcher(_namespaceNavigatorCache,
                                                                settings.MinimumLevel.HasValue
                    ? settings.MinimumLevel.Value.GetName()
                    : LogLevel.TryGetValue("Default", out var x)
                        ? x
                        : LogEventLevelConstants.Verbose);

            foreach (var item in Aliases)
            {
                LogEventLevelAliasManager.AddAlias(item.Key, LogEventLevelConverter.Convert(item.Value));
            }
        }
        internal static void SetSinkFilterNavMatcher(string name, INamespaceNavigationMatcher matcher, string defaultLevel)
        {
            if (string.IsNullOrWhiteSpace(name))
            {
                throw new ArgumentNullException(nameof(name));
            }
            if (matcher == null)
            {
                throw new ArgumentNullException(nameof(matcher));
            }

            lock (_sinkFilterNavMatcherLock) {
                if (_sinkFilterNavMatchers.ContainsKey(name))
                {
                    _sinkFilterNavMatchers[name] = matcher;
                    _defaultLevel[name]          = LogEventLevelConverter.Convert(defaultLevel);
                }
                else
                {
                    _sinkFilterNavMatchers.Add(name, matcher);
                    _defaultLevel.Add(name, LogEventLevelConverter.Convert(defaultLevel));
                }
            }
        }
Пример #4
0
 /// <inheritdoc />
 public EndValueNamespaceNavigationNode(string level) : base("EndValue")
 {
     Level = LogEventLevelConverter.Convert(level);
 }
 private static string FixedEventLevel(LogEventLevel level, int aliasLength)
 {
     return(aliasLength <= 0
         ? LogEventLevelConverter.Convert(level)
         : LogEventLevelConverter.Convert(level, aliasLength));
 }
 private static string FixedEventLevel(ILogEventInfo logEventInfo, int aliasLength)
 {
     return(aliasLength <= 0
         ? LogEventLevelConverter.Convert(logEventInfo?.Level)
         : LogEventLevelConverter.Convert(logEventInfo?.Level, aliasLength));
 }