示例#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);
        }