Try logging *literally everything*

This commit is contained in:
Ske 2019-12-23 14:44:20 +01:00
parent f2ce09d467
commit 5448f734d4
2 changed files with 22 additions and 1 deletions

View File

@ -53,7 +53,6 @@ namespace PluralKit.Bot
using (Sentry.SentrySdk.Init(coreConfig.SentryUrl))
{
logger.Information("Connecting to database");
using (var conn = await services.GetRequiredService<DbConnectionFactory>().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;

View File

@ -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}" ))}");
}
}
}