예제 #1
0
        public void ConsoleLoggerOptions_TimeStampFormat_MultipleReloads()
        {
            var monitor        = new TestOptionsMonitor(new ConsoleLoggerOptions());
            var loggerProvider = new ConsoleLoggerProvider(monitor);
            var logger         = (ConsoleLogger)loggerProvider.CreateLogger("Name");

            Assert.Null(logger.Options.TimestampFormat);
            monitor.Set(new ConsoleLoggerOptions()
            {
                TimestampFormat = "yyyyMMdd"
            });
            Assert.Equal("yyyyMMdd", logger.Options.TimestampFormat);
            monitor.Set(new ConsoleLoggerOptions()
            {
                TimestampFormat = "yyyyMMddHHmmss"
            });
            Assert.Equal("yyyyMMddHHmmss", logger.Options.TimestampFormat);
        }
예제 #2
0
        public void ConsoleLoggerOptions_LogAsErrorLevel_IsAppliedToLoggers()
        {
            // Arrange
            var monitor        = new TestOptionsMonitor(new ConsoleLoggerOptions());
            var loggerProvider = new ConsoleLoggerProvider(monitor);
            var logger         = (ConsoleLogger)loggerProvider.CreateLogger("Name");

            // Act & Assert
            Assert.Equal(LogLevel.None, logger.Options.LogToStandardErrorThreshold);
            monitor.Set(new ConsoleLoggerOptions()
            {
                LogToStandardErrorThreshold = LogLevel.Error
            });
            Assert.Equal(LogLevel.Error, logger.Options.LogToStandardErrorThreshold);
        }
예제 #3
0
        public void ConsoleLoggerOptions_DisableColors_IsReloaded()
        {
            // Arrange
            var monitor        = new TestOptionsMonitor(new ConsoleLoggerOptions());
            var loggerProvider = new ConsoleLoggerProvider(monitor);
            var logger         = (ConsoleLogger)loggerProvider.CreateLogger("Name");

            // Act & Assert
            Assert.Null(logger.Options.TimestampFormat);
            monitor.Set(new ConsoleLoggerOptions()
            {
                TimestampFormat = "yyyyMMddHHmmss"
            });
            Assert.Equal("yyyyMMddHHmmss", logger.Options.TimestampFormat);
        }
예제 #4
0
        public void ConsoleLoggerOptions_IncludeScopes_IsAppliedToLoggers()
        {
            // Arrange
            var monitor = new TestOptionsMonitor(new ConsoleLoggerOptions()
            {
                IncludeScopes = true
            });
            var loggerProvider = new ConsoleLoggerProvider(monitor);
            var logger         = (ConsoleLogger)loggerProvider.CreateLogger("Name");

            // Act & Assert
            Assert.True(logger.Options.IncludeScopes);
            monitor.Set(new ConsoleLoggerOptions()
            {
                IncludeScopes = false
            });
            Assert.False(logger.Options.IncludeScopes);
        }