Example #1
0
 /// <summary>
 /// Initializes a new instance of the <see cref="LoggerAdapter{TLoglevel}"/> class.
 /// </summary>
 /// <param name="logfile">The logfile.</param>
 /// <param name="categoryName">The category name.</param>
 /// <param name="loglevelConversion">The callback method to convert an ASP.NET Core
 ///		loglevel into a Logfile loglevel.</param>
 /// <exception cref="ArgumentNullException">Thrown if
 ///		<paramref name="logfile"/> is null.</exception>
 public LoggerAdapter(ILogfileProxy <TLoglevel> logfile, string categoryName,
                      Func <LogLevel, TLoglevel> loglevelConversion)
 {
     this.Logfile = logfile ?? throw new ArgumentNullException(nameof(logfile));
     CategoryName = categoryName;
     this.loglevelConversionCallback = loglevelConversion ?? throw new ArgumentNullException(nameof(loglevelConversion));
 }
        public static ILoggingBuilder AddLogfile <TLoglevel>(this ILoggingBuilder builder, ILogfileProxy <TLoglevel> logfile,
                                                             Func <LogLevel, TLoglevel> loglevelConversion)
            where TLoglevel : Enum
        {
            if (builder == null)
            {
                throw new ArgumentNullException(nameof(builder));
            }
            if (logfile == null)
            {
                throw new ArgumentNullException(nameof(logfile));
            }
            if (loglevelConversion == null)
            {
                throw new ArgumentNullException(nameof(loglevelConversion));
            }

            builder.AddProvider(new LoggerProvider <TLoglevel>(logfile, loglevelConversion));
            return(builder);
        }
 public StandardLoggerProvider(ILogfileProxy <StandardLoglevel> logfile)
     : base(logfile, StandardLoglevelConversion)
 {
 }
 public LogController(ILogfileProxy <StandardLoglevel> logfile)
 {
     this.logfile = logfile;
 }
 public LoggerProvider(ILogfileProxy <TLoglevel> logfile, Func <LogLevel, TLoglevel> loglevelConversion)
 {
     this.Logfile            = logfile ?? throw new ArgumentNullException(nameof(logfile));
     this.loglevelConversion = loglevelConversion ?? throw new ArgumentNullException(nameof(loglevelConversion));
     this.loggers            = new ConcurrentDictionary <string, ILogger>(StringComparer.CurrentCulture);
 }