From b4ad1e504161303a2ac1bc910e6a670524668864 Mon Sep 17 00:00:00 2001 From: Ske Date: Mon, 23 Dec 2019 00:29:30 +0100 Subject: [PATCH] Use asynchronous logging --- PluralKit.Core/PluralKit.Core.csproj | 1 + PluralKit.Core/Utils.cs | 18 ++++++++++-------- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/PluralKit.Core/PluralKit.Core.csproj b/PluralKit.Core/PluralKit.Core.csproj index 9d558647..55a961b2 100644 --- a/PluralKit.Core/PluralKit.Core.csproj +++ b/PluralKit.Core/PluralKit.Core.csproj @@ -22,6 +22,7 @@ + diff --git a/PluralKit.Core/Utils.cs b/PluralKit.Core/Utils.cs index ad42d7d9..b671a890 100644 --- a/PluralKit.Core/Utils.cs +++ b/PluralKit.Core/Utils.cs @@ -323,14 +323,16 @@ namespace PluralKit return new LoggerConfiguration() .ConfigureForNodaTime(DateTimeZoneProviders.Tzdb) .MinimumLevel.Debug() - .WriteTo.File( - new RenderedCompactJsonFormatter(), - (config.LogDir ?? "logs") + $"/pluralkit.{component}.log", - rollingInterval: RollingInterval.Day, - flushToDiskInterval: TimeSpan.FromSeconds(10), - restrictedToMinimumLevel: LogEventLevel.Information, - buffered: true) - .WriteTo.Console(theme: AnsiConsoleTheme.Code, outputTemplate:"[{Timestamp:HH:mm:ss}] [{EventId}] {Level:u3} {Message:lj}{NewLine}{Exception}") + .WriteTo.Async(a => + a.File( + new RenderedCompactJsonFormatter(), + (config.LogDir ?? "logs") + $"/pluralkit.{component}.log", + rollingInterval: RollingInterval.Day, + flushToDiskInterval: TimeSpan.FromSeconds(10), + restrictedToMinimumLevel: LogEventLevel.Information, + buffered: true)) + .WriteTo.Async(a => + a.Console(theme: AnsiConsoleTheme.Code, outputTemplate:"[{Timestamp:HH:mm:ss}] [{EventId}] {Level:u3} {Message:lj}{NewLine}{Exception}")) .CreateLogger(); }