feat: logging refactor

- added ability to debug by key
- started on being able to switch out the websockete based on target env
- added in comprehensive log methods to debug class
This commit is contained in:
Nick Genovese
2024-11-01 15:00:03 -04:00
parent 56263df116
commit de5b5eafff
13 changed files with 1001 additions and 1534 deletions

View File

@@ -1,35 +1,27 @@
using Crestron.SimplSharp;
using Serilog.Core;
using Serilog.Events;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace PepperDash.Core.Logging
{
public class CrestronEnricher : ILogEventEnricher
{
static readonly string _appName;
private static readonly string AppName;
static CrestronEnricher()
{
switch (CrestronEnvironment.DevicePlatform)
AppName = CrestronEnvironment.DevicePlatform switch
{
case eDevicePlatform.Appliance:
_appName = $"App {InitialParametersClass.ApplicationNumber}";
break;
case eDevicePlatform.Server:
_appName = $"{InitialParametersClass.RoomId}";
break;
}
eDevicePlatform.Appliance => $"App {InitialParametersClass.ApplicationNumber}",
eDevicePlatform.Server => $"{InitialParametersClass.RoomId}",
_ => string.Empty
};
}
public void Enrich(LogEvent logEvent, ILogEventPropertyFactory propertyFactory)
{
var property = propertyFactory.CreateProperty("App", _appName);
var property = propertyFactory.CreateProperty("App", AppName);
logEvent.AddOrUpdateProperty(property);
}