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>();
        }
예제 #2
0
 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));
 }
예제 #3
0
        /// <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));
        }
예제 #4
0
        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);
        }
예제 #5
0
        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);
        }