PluralKit/PluralKit.Bot/PKPerformanceEventListener.cs
2019-12-23 14:44:20 +01:00

20 lines
676 B
C#

using System;
using System.Diagnostics.Tracing;
using System.Linq;
namespace PluralKit.Bot {
class PKPerformanceEventListener: EventListener
{
public PKPerformanceEventListener()
{
foreach (var s in EventSource.GetSources())
EnableEvents(s, EventLevel.Informational);
}
protected override void OnEventWritten(EventWrittenEventArgs eventData)
{
base.OnEventWritten(eventData);
Console.WriteLine($"{eventData.EventSource.Name}/{eventData.EventName}: {string.Join(", ", eventData.PayloadNames.Zip(eventData.Payload).Select(v => $"{v.First}={v.Second}" ))}");
}
}
}