diff --git a/Source/ExcelRna.Extensions.Logging.Tests/LogDisplayLoggerTests.cs b/Source/ExcelRna.Extensions.Logging.Tests/LogDisplayLoggerTests.cs index f841b0a..52482c6 100644 --- a/Source/ExcelRna.Extensions.Logging.Tests/LogDisplayLoggerTests.cs +++ b/Source/ExcelRna.Extensions.Logging.Tests/LogDisplayLoggerTests.cs @@ -102,7 +102,7 @@ public void Log_includes_timestamp() // ARRANGE var logger = new LogDisplayLogger("Test", new LogDisplayLoggerOptions { - TimestampFormat = "yyyy-MM-dd HH:mm:ss ", + TimestampFormat = "yyyy-MM-dd HH:mm:ss", }) { RecordLine = Mock.Of>(), @@ -158,17 +158,4 @@ public void Log_does_not_show_LogDisplay(LogLevel level) // ASSERT Mock.Get(logger.Show).Verify(invoke => invoke(), Times.Never); } - - [Fact] - public void Log_throws_when_logLevel_is_wrong() - { - // ARRANGE - var logger = new LogDisplayLogger("Test"); - - // ACT & ASSERT - Assert.Throws(() => - { - logger.Log((LogLevel)100, new Exception("TestException"), "TestMessage"); - }); - } } diff --git a/Source/ExcelRna.Extensions.Logging/LogDisplayLogger.cs b/Source/ExcelRna.Extensions.Logging/LogDisplayLogger.cs index d4b692d..af00617 100644 --- a/Source/ExcelRna.Extensions.Logging/LogDisplayLogger.cs +++ b/Source/ExcelRna.Extensions.Logging/LogDisplayLogger.cs @@ -67,10 +67,11 @@ public void Log(LogLevel logLevel, EventId eventId, TState state, Except builder.Append(" "); } - builder.Append(GetLogLevelString(logLevel)); - builder.Append(": "); + builder.Append("["); + builder.Append(logLevel); + builder.Append("] "); builder.Append(_name); - builder.Append(" "); + builder.Append(": "); builder.Append(message); if (exception != null) @@ -86,18 +87,4 @@ public void Log(LogLevel logLevel, EventId eventId, TState state, Except Show(); } } - - private static string GetLogLevelString(LogLevel logLevel) - { - return logLevel switch - { - LogLevel.Trace => "trce", - LogLevel.Debug => "dbug", - LogLevel.Information => "info", - LogLevel.Warning => "warn", - LogLevel.Error => "fail", - LogLevel.Critical => "crit", - _ => throw new ArgumentOutOfRangeException(nameof(logLevel)) - }; - } }