Files
CounterStrikeSharp/managed/CounterStrikeSharp.API/Core/Logging/PluginNameEnricher.cs
2023-11-21 16:42:56 +10:00

22 lines
586 B
C#

using Serilog.Core;
using Serilog.Events;
namespace CounterStrikeSharp.API.Core.Logging;
public class PluginNameEnricher : ILogEventEnricher
{
public const string PropertyName = "PluginName";
public PluginNameEnricher(PluginContext pluginContext)
{
Context = pluginContext;
}
public PluginContext Context { get; }
public void Enrich(LogEvent logEvent, ILogEventPropertyFactory propertyFactory)
{
var property = propertyFactory.CreateProperty(PropertyName, Context.PluginType.Name);
logEvent.AddPropertyIfAbsent(property);
}
}