mirror of
https://github.com/PepperDash/PepperDashCore.git
synced 2026-04-12 20:16:34 +00:00
feat: Add enricher to automatically add App property to all messages
This enricher can be enhanced in the future to add additional properties that we might want without affecting anything else.
This commit is contained in:
parent
2e8edfc395
commit
5bdd9e02bb
1 changed files with 38 additions and 0 deletions
38
src/Pepperdash Core/Logging/CrestronEnricher.cs
Normal file
38
src/Pepperdash Core/Logging/CrestronEnricher.cs
Normal file
|
|
@ -0,0 +1,38 @@
|
|||
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;
|
||||
|
||||
static CrestronEnricher()
|
||||
{
|
||||
if(CrestronEnvironment.DevicePlatform == eDevicePlatform.Appliance)
|
||||
{
|
||||
_appName = $"App {InitialParametersClass.ApplicationNumber}";
|
||||
return;
|
||||
}
|
||||
|
||||
if(CrestronEnvironment.DevicePlatform == eDevicePlatform.Server)
|
||||
{
|
||||
_appName = $"Room {InitialParametersClass.RoomId}";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void Enrich(LogEvent logEvent, ILogEventPropertyFactory propertyFactory)
|
||||
{
|
||||
var property = propertyFactory.CreateProperty("App", _appName);
|
||||
|
||||
logEvent.AddOrUpdateProperty(property);
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue