Files
PepperDashCore/src/Pepperdash.Core/Logging/CrestronEnricher.cs
2024-11-05 13:16:46 -05:00

29 lines
856 B
C#

using Crestron.SimplSharp;
using Serilog.Core;
using Serilog.Events;
namespace PepperDash.Core.Logging
{
public class CrestronEnricher : ILogEventEnricher
{
private static readonly string AppName;
static CrestronEnricher()
{
AppName = CrestronEnvironment.DevicePlatform switch
{
eDevicePlatform.Appliance => $"APP{InitialParametersClass.ApplicationNumber.ToString().PadLeft(2, '0')}",
eDevicePlatform.Server => $"{InitialParametersClass.RoomId}",
_ => string.Empty
};
}
public void Enrich(LogEvent logEvent, ILogEventPropertyFactory propertyFactory)
{
var property = propertyFactory.CreateProperty("App", AppName);
logEvent.AddOrUpdateProperty(property);
}
}
}