public LykkeConsoleLoggerProvider( [NotNull] ConsoleLoggerOptions options, [NotNull] IConsoleLogMessageWriter messageWriter) { _options = options ?? throw new ArgumentNullException(nameof(options)); _messageWriter = messageWriter ?? throw new ArgumentNullException(nameof(messageWriter)); _loggers = new ConcurrentDictionary <string, LykkeConsoleLogger>(); }
public LykkeConsoleLogger( [NotNull] string componentName, [NotNull] IConsoleLogMessageWriter writer, [NotNull] ConsoleLoggerOptions options) { _componentName = componentName ?? throw new ArgumentNullException(nameof(componentName)); _options = options ?? throw new ArgumentNullException(nameof(options)); _writer = writer ?? throw new ArgumentNullException(nameof(writer)); }
/// <summary> /// Adds an unbuffered console logger. /// Useful for tests. /// </summary> /// <param name="factory">The <see cref="ILogFactory"/> to use.</param> /// <param name="configure">Optional configuration</param> public static ILogFactory AddUnbufferedConsole( [NotNull] this ILogFactory factory, Action <ConsoleLoggerOptions> configure = null) { var options = new ConsoleLoggerOptions(); configure?.Invoke(options); return(factory.AddConsole(options, ConsoleLogMessageWriter.Instance)); }
private static ILogFactory AddConsole( [NotNull] this ILogFactory factory, [NotNull] ConsoleLoggerOptions options, [NotNull] IConsoleLogMessageWriter messageWriter) { if (factory == null) { throw new ArgumentNullException(nameof(factory)); } factory.AddProvider(new LykkeConsoleLoggerProvider(options, messageWriter)); return(factory); }
public static ILogBuilder AddConsole( [NotNull] this ILogBuilder builder, [CanBeNull] Action <ConsoleLoggerOptions> configure = null) { if (builder == null) { throw new ArgumentNullException(nameof(builder)); } var options = new ConsoleLoggerOptions(); configure?.Invoke(options); builder.Services.AddSingleton <ILoggerProvider, LykkeConsoleLoggerProvider>(s => new LykkeConsoleLoggerProvider( options, new BufferedConsoleLogMessageWriterDecorator(ConsoleLogMessageWriter.Instance))); return(builder); }