Пример #1
0
        public void Can_AddProvider_Create_Logger() {
            ILoggerFactory factory = new LoggerFactory();

            var provicer1 = new ConsoleLoggerProvider(LogLevel.Error);
            var provicer2 = new ConsoleLoggerProvider(LogLevel.Debug);

            factory.AddProvider(new[] { provicer1, provicer2 });

            var logger = factory.CreateLogger(this.GetType().Name);

            Assert.True(logger.IsEnabled(LogLevel.Debug));
        }
Пример #2
0
        public void Create_ConsoleProvider_With_Level() {
            var provider = new ConsoleLoggerProvider(LogLevel.Debug);

            var logger = provider.CreateLogger(this.GetType().FullName);

            Assert.False(logger.IsEnabled(LogLevel.Trace));

            Assert.True(logger.IsEnabled(LogLevel.Debug));
            Assert.True(logger.IsEnabled(LogLevel.Info));
            Assert.True(logger.IsEnabled(LogLevel.Warn));
            Assert.True(logger.IsEnabled(LogLevel.Error));
            Assert.True(logger.IsEnabled(LogLevel.Fatal));
        }
Пример #3
0
        public void Can_Create_Logger_And_Append_Provider_() {
            ILoggerFactory factory = new LoggerFactory();

            var provicer1 = new ConsoleLoggerProvider(LogLevel.Error);

            factory.AddProvider(provicer1);

            var logger = factory.CreateLogger<LoggerTest>();

            Assert.False(logger.IsEnabled(LogLevel.Debug));

            var provicer2 = new ConsoleLoggerProvider(LogLevel.Debug);

            //append provider
            factory.AddProvider(provicer2);

            Assert.True(logger.IsEnabled(LogLevel.Debug));
        }