fix: update logging format to include key

This commit is contained in:
Andrew Welker
2024-03-08 08:47:43 -06:00
parent bf7b1f4b58
commit ada8b7e162
3 changed files with 21 additions and 17 deletions

View File

@@ -20,19 +20,21 @@ namespace PepperDash.Core
public void Emit(LogEvent logEvent)
{
if (!Debug.IsRunningOnAppliance) return;
if (!Debug.IsRunningOnAppliance) return;
CrestronConsole.PrintLine("[{0}][App {1}][Lvl {2}]: {3}", logEvent.Timestamp,
InitialParametersClass.ApplicationNumber,
logEvent.Level,
logEvent.RenderMessage());
string message = $"[{logEvent.Timestamp}][{logEvent.Level}][App {InitialParametersClass.ApplicationNumber}]{logEvent.RenderMessage()}";
if(logEvent.Properties.TryGetValue("Key",out var value) && value is ScalarValue sv && sv.Value is string rawValue)
{
message = $"[{logEvent.Timestamp}][{logEvent.Level}][App {InitialParametersClass.ApplicationNumber}][{rawValue}]: {logEvent.RenderMessage()}";
}
CrestronConsole.PrintLine(message);
}
public DebugConsoleSink(ITextFormatter formatProvider)
public DebugConsoleSink(ITextFormatter formatProvider )
{
_textFormatter = formatProvider ?? new JsonFormatter();
}
}