コード例 #1
0
 private void ReloadLoggerOptions(ConsoleLoggerOptions options)
 {
     foreach (var logger in _loggers)
     {
         logger.Value.Options = options;
     }
 }
コード例 #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;
            }
        }
コード例 #3
0
 private void ReloadLoggerOptions(ConsoleLoggerOptions options)
 {
     foreach (System.Collections.Generic.KeyValuePair <string, ConsoleLogger> logger in _loggers)
     {
         logger.Value.Options = options;
     }
 }
コード例 #4
0
 private void ReloadLoggerOptions(ConsoleLoggerOptions options)
 {
     _includeScopes = options.IncludeScopes;
     foreach (var logger in _loggers.Values)
     {
         logger.IncludeScopes = _includeScopes;
     }
 }
コード例 #5
0
        private void ReloadLoggerOptions(ConsoleLoggerOptions options)
        {
            foreach (var logger in _loggers)
            {
                logger.Value.Options = options;
            }

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

            foreach (var logger in _loggers.Values)
            {
                logger.ScopeProvider = scopeProvider;
            }
        }
コード例 #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;
            }
        }
コード例 #8
0
ファイル: ConsoleLogger.cs プロジェクト: pedrobsaila/runtime
        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;
        }
コード例 #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,
                };
            }
        }