mirror of
https://github.com/PluralKit/PluralKit.git
synced 2026-02-09 15:27:54 +00:00
Add logger to API service setup
This commit is contained in:
parent
961bfe9094
commit
0b4335ccaa
5 changed files with 24 additions and 16 deletions
|
|
@ -13,6 +13,9 @@ using NodaTime;
|
|||
using NodaTime.Serialization.JsonNet;
|
||||
using NodaTime.Text;
|
||||
using Npgsql;
|
||||
using Serilog;
|
||||
using Serilog.Formatting.Compact;
|
||||
using Serilog.Sinks.SystemConsole.Themes;
|
||||
|
||||
|
||||
namespace PluralKit
|
||||
|
|
@ -299,6 +302,20 @@ namespace PluralKit
|
|||
SqlMapper.AddTypeHandler(new PassthroughTypeHandler<LocalDate>());
|
||||
}
|
||||
|
||||
public static ILogger InitLogger(CoreConfig config, string component)
|
||||
{
|
||||
return new LoggerConfiguration()
|
||||
.ConfigureForNodaTime(DateTimeZoneProviders.Tzdb)
|
||||
.WriteTo.File(
|
||||
new CompactJsonFormatter(),
|
||||
(config.LogDir ?? "logs") + $"/pluralkit.{component}.log",
|
||||
rollingInterval: RollingInterval.Day,
|
||||
flushToDiskInterval: TimeSpan.FromSeconds(10),
|
||||
buffered: true)
|
||||
.WriteTo.Console(theme: AnsiConsoleTheme.Code)
|
||||
.CreateLogger();
|
||||
}
|
||||
|
||||
public static JsonSerializerSettings BuildSerializerSettings() => new JsonSerializerSettings().BuildSerializerSettings();
|
||||
|
||||
public static JsonSerializerSettings BuildSerializerSettings(this JsonSerializerSettings settings)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue