refactor: update log message format for console

This commit is contained in:
Andrew Welker
2024-05-15 23:37:39 -05:00
parent 14e6aa4dc8
commit d7f57439c8

View File

@@ -148,7 +148,7 @@ namespace PepperDash.Core
.MinimumLevel.Verbose()
.Enrich.FromLogContext()
.Enrich.With(new CrestronEnricher())
.WriteTo.Sink(new DebugConsoleSink(new ExpressionTemplate("[{@t}][{@l}][{App}][{Key:3}]{@m}\n{@x}")), levelSwitch: _consoleLoggingLevelSwitch)
.WriteTo.Sink(new DebugConsoleSink(new ExpressionTemplate("[{@t:yyyy-MM-dd HH:mm:ss.fff}][{@l:u4}][{App}]{#if Key is not null}[{Key}]{#end} {@m}{#if @x is not null}\r\n{@x}{#end}")), levelSwitch: _consoleLoggingLevelSwitch)
.WriteTo.Sink(_websocketSink, levelSwitch: _websocketLoggingLevelSwitch)
.WriteTo.Sink(new DebugErrorLogSink(), levelSwitch: _errorLogLevelSwitch)
.WriteTo.File(new RenderedCompactJsonFormatter(), logFilePath,
@@ -593,7 +593,7 @@ namespace PepperDash.Core
/// <param name="args">Args to put into message template</param>
public static void LogMessage(Exception ex, string message, IKeyed device = null, params object[] args)
{
using (LogContext.PushProperty("Key", device?.Key ?? string.Empty))
using (LogContext.PushProperty("Key", device?.Key))
{
_logger.Error(ex, message, args);
}
@@ -608,7 +608,7 @@ namespace PepperDash.Core
/// <param name="args">Args to put into message template</param>
public static void LogMessage(LogEventLevel level, string message, IKeyed device=null, params object[] args)
{
using (LogContext.PushProperty("Key", device?.Key ?? string.Empty))
using (LogContext.PushProperty("Key", device?.Key))
{
_logger.Write(level, message, args);
}