From 573f89c174a8651b9ad6cad35d695a55867a6720 Mon Sep 17 00:00:00 2001 From: walterlv Date: Thu, 22 Aug 2024 11:56:02 +0800 Subject: [PATCH] =?UTF-8?q?=E5=9C=A8=E5=88=87=E6=8D=A2=E7=BA=BF=E7=A8=8B?= =?UTF-8?q?=E5=89=8D=EF=BC=8C=E5=85=88=E6=8A=8A=E6=97=A5=E5=BF=97=E6=97=B6?= =?UTF-8?q?=E9=97=B4=E7=BB=99=E6=8D=95=E8=8E=B7=E4=BA=86=EF=BC=8C=E9=81=BF?= =?UTF-8?q?=E5=85=8D=E6=97=A5=E5=BF=97=E6=97=B6=E9=97=B4=E4=B8=8E=E5=AE=9E?= =?UTF-8?q?=E9=99=85=E4=B8=8D=E7=AC=A6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Writers/ConsoleLogger.cs | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/src/dotnetCampus.Logger/Writers/ConsoleLogger.cs b/src/dotnetCampus.Logger/Writers/ConsoleLogger.cs index 53b1396..db38b54 100644 --- a/src/dotnetCampus.Logger/Writers/ConsoleLogger.cs +++ b/src/dotnetCampus.Logger/Writers/ConsoleLogger.cs @@ -66,14 +66,20 @@ public void Log(LogLevel logLevel, EventId eventId, TState state, Except return; } + var traceTag = TraceTag; + var debugTag = DebugTag; + var informationTag = InformationTag; + var warningTag = WarningTag; + var errorTag = ErrorTag; + var criticalTag = CriticalTag; LogCore(logLevel, exception, message, m => logLevel switch { - LogLevel.Trace => $"{TraceTag} {TraceText}{m}{Reset}", - LogLevel.Debug => $"{DebugTag} {DebugText}{m}{Reset}", - LogLevel.Information => $"{InformationTag} {InformationText}{m}{Reset}", - LogLevel.Warning => $"{WarningTag} {WarningText}{m}{Reset}", - LogLevel.Error => $"{ErrorTag} {ErrorText}{m}{Reset}", - LogLevel.Critical => $"{CriticalTag} {CriticalText}{m}{Reset}", + LogLevel.Trace => $"{traceTag} {TraceText}{m}{Reset}", + LogLevel.Debug => $"{debugTag} {DebugText}{m}{Reset}", + LogLevel.Information => $"{informationTag} {InformationText}{m}{Reset}", + LogLevel.Warning => $"{warningTag} {WarningText}{m}{Reset}", + LogLevel.Error => $"{errorTag} {ErrorText}{m}{Reset}", + LogLevel.Critical => $"{criticalTag} {CriticalText}{m}{Reset}", _ => null, }); }