From 5448f734d4600e463dce5f23d09956190c0b5c06 Mon Sep 17 00:00:00 2001 From: Ske Date: Mon, 23 Dec 2019 14:44:20 +0100 Subject: [PATCH] Try logging *literally everything* --- PluralKit.Bot/Bot.cs | 3 ++- PluralKit.Bot/PKPerformanceEventListener.cs | 20 ++++++++++++++++++++ 2 files changed, 22 insertions(+), 1 deletion(-) create mode 100644 PluralKit.Bot/PKPerformanceEventListener.cs diff --git a/PluralKit.Bot/Bot.cs b/PluralKit.Bot/Bot.cs index 63db07a7..e337f2a5 100644 --- a/PluralKit.Bot/Bot.cs +++ b/PluralKit.Bot/Bot.cs @@ -53,7 +53,6 @@ namespace PluralKit.Bot using (Sentry.SentrySdk.Init(coreConfig.SentryUrl)) { - logger.Information("Connecting to database"); using (var conn = await services.GetRequiredService().Obtain()) await Schema.CreateTables(conn); @@ -144,9 +143,11 @@ namespace PluralKit.Bot private IMetrics _metrics; private PeriodicStatCollector _collector; private ILogger _logger; + private PKPerformanceEventListener _pl; public Bot(IServiceProvider services, IDiscordClient client, IMetrics metrics, PeriodicStatCollector collector, ILogger logger) { + _pl = new PKPerformanceEventListener(); _services = services; _client = client as DiscordShardedClient; _metrics = metrics; diff --git a/PluralKit.Bot/PKPerformanceEventListener.cs b/PluralKit.Bot/PKPerformanceEventListener.cs new file mode 100644 index 00000000..1a350860 --- /dev/null +++ b/PluralKit.Bot/PKPerformanceEventListener.cs @@ -0,0 +1,20 @@ +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}" ))}"); + } + } +} \ No newline at end of file