private void ReloadLoggerOptions(ConsoleLoggerOptions options)
 {
     foreach (var logger in _loggers)
     {
         logger.Value.Options = options;
     }
 }
Example #2
0
        // warning:  ReloadLoggerOptions can be called before the ctor completed,... before registering all of the state used in this method need to be initialized
        private void ReloadLoggerOptions(ConsoleLoggerOptions options)
        {
            if (options.FormatterName == null || !_formatters.TryGetValue(options.FormatterName, out ConsoleFormatter? logFormatter))
            {
#pragma warning disable CS0618
                logFormatter = options.Format switch
                {
                    ConsoleLoggerFormat.Systemd => _formatters[ConsoleFormatterNames.Systemd],
                    _ => _formatters[ConsoleFormatterNames.Simple],
                };
                if (options.FormatterName == null)
                {
                    UpdateFormatterOptions(logFormatter, options);
                }
#pragma warning restore CS0618
            }

            _messageQueue.FullMode       = options.QueueFullMode;
            _messageQueue.MaxQueueLength = options.MaxQueueLength;

            foreach (KeyValuePair <string, ConsoleLogger> logger in _loggers)
            {
                logger.Value.Options   = options;
                logger.Value.Formatter = logFormatter;
            }
        }
 private void ReloadLoggerOptions(ConsoleLoggerOptions options)
 {
     foreach (System.Collections.Generic.KeyValuePair <string, ConsoleLogger> logger in _loggers)
     {
         logger.Value.Options = options;
     }
 }
Example #4
0
 private void ReloadLoggerOptions(ConsoleLoggerOptions options)
 {
     _includeScopes = options.IncludeScopes;
     foreach (var logger in _loggers.Values)
     {
         logger.IncludeScopes = _includeScopes;
     }
 }
Example #5
0
        private void ReloadLoggerOptions(ConsoleLoggerOptions options)
        {
            foreach (var logger in _loggers)
            {
                logger.Value.Options = options;
            }

            _optionsReloadToken = _options.OnChange(ReloadLoggerOptions);
        }
Example #6
0
        private void ReloadLoggerOptions(ConsoleLoggerOptions options)
        {
            _includeScopes = options.IncludeScopes;
            var scopeProvider = GetScopeProvider();

            foreach (var logger in _loggers.Values)
            {
                logger.ScopeProvider = scopeProvider;
            }
        }
Example #7
0
        private void ReloadLoggerOptions(ConsoleLoggerOptions options)
        {
            _includeScopes   = options.IncludeScopes;
            _disableColors   = options.DisableColors;
            _timestampFormat = options.TimestampFormat;
            var scopeProvider = GetScopeProvider();

            foreach (var logger in _loggers.Values)
            {
                logger.ScopeProvider   = scopeProvider;
                logger.DisableColors   = options.DisableColors;
                logger.TimestampFormat = options.TimestampFormat;
            }
        }
Example #8
0
        internal ConsoleLogger(
            string name,
            ConsoleLoggerProcessor loggerProcessor,
            ConsoleFormatter formatter,
            IExternalScopeProvider?scopeProvider,
            ConsoleLoggerOptions options)
        {
            ThrowHelper.ThrowIfNull(name);

            _name           = name;
            _queueProcessor = loggerProcessor;
            Formatter       = formatter;
            ScopeProvider   = scopeProvider;
            Options         = options;
        }
Example #9
0
#pragma warning disable CS0618
        private void UpdateFormatterOptions(ConsoleFormatter formatter, ConsoleLoggerOptions deprecatedFromOptions)
        {
            // kept for deprecated apis:
            if (formatter is SimpleConsoleFormatter defaultFormatter)
            {
                defaultFormatter.FormatterOptions = new SimpleConsoleFormatterOptions()
                {
                    ColorBehavior   = deprecatedFromOptions.DisableColors ? LoggerColorBehavior.Disabled : LoggerColorBehavior.Enabled,
                    IncludeScopes   = deprecatedFromOptions.IncludeScopes,
                    TimestampFormat = deprecatedFromOptions.TimestampFormat,
                    UseUtcTimestamp = deprecatedFromOptions.UseUtcTimestamp,
                };
            }
            else
            if (formatter is SystemdConsoleFormatter systemdFormatter)
            {
                systemdFormatter.FormatterOptions = new ConsoleFormatterOptions()
                {
                    IncludeScopes   = deprecatedFromOptions.IncludeScopes,
                    TimestampFormat = deprecatedFromOptions.TimestampFormat,
                    UseUtcTimestamp = deprecatedFromOptions.UseUtcTimestamp,
                };
            }
        }