private static SingleLineConsoleMessageFormatter CreateFormatter(Action <SingleLineConsoleLoggerOptions> configAction)
        {
            var config = new SingleLineConsoleLoggerOptions();

            configAction(config);
            return(new SingleLineConsoleMessageFormatter(config));
        }
        public SingleLineConsoleLoggerSink(SingleLineConsoleLoggerOptions options)
        {
            _renderer = new ActionBlock <ConsoleMessage>(RenderMessage);
            _sink     = new TransformManyBlock <LogMessageEntry, ConsoleMessage>(ProcessMessage, new ExecutionDataflowBlockOptions {
                MaxDegreeOfParallelism = 100
            });                                                                                                                                                  // todo: think about magic number

            var linkOptions = new DataflowLinkOptions {
                PropagateCompletion = true
            };

            _sink.LinkTo(_renderer, linkOptions);

            WithOptions(options);
        }
 public SingleLineConsoleLogger(string name, ILoggerSink sink, SingleLineConsoleLoggerOptions options, IExternalScopeProvider scopeProvider)
 {
     _name          = name;
     _sink          = sink;
     _scopeProvider = scopeProvider;
 }
 public void WithOptions(SingleLineConsoleLoggerOptions options) => _formatter = new SingleLineConsoleMessageFormatter(options);
Exemple #5
0
 private void ReloadOptions(SingleLineConsoleLoggerOptions options) => _sink.WithOptions(options);
Exemple #6
0
 public SingleLineConsoleMessageFormatter(SingleLineConsoleLoggerOptions options)
 {
     _timestampFormat = GetDateTimeFormat(options.TimestampFormat);
     _levelMap        = GetLogLevelMapping(options.LevelFormat);
     _options         = options;
 }