mirror of
https://github.com/PluralKit/PluralKit.git
synced 2026-02-04 04:56:49 +00:00
feat(apiv2): basic error handling
This commit is contained in:
parent
9bafc732ab
commit
9d47bfe0d8
3 changed files with 82 additions and 3 deletions
|
|
@ -17,11 +17,13 @@ namespace PluralKit.Core
|
|||
{
|
||||
private readonly string _component;
|
||||
private readonly Action<LoggerConfiguration> _fn;
|
||||
private LoggerConfiguration _cfg { get; init; }
|
||||
|
||||
public LoggingModule(string component, Action<LoggerConfiguration> fn = null)
|
||||
public LoggingModule(string component, Action<LoggerConfiguration> fn = null, LoggerConfiguration cfg = null)
|
||||
{
|
||||
_component = component;
|
||||
_fn = fn ?? (_ => { });
|
||||
_cfg = cfg ?? new LoggerConfiguration();
|
||||
}
|
||||
|
||||
protected override void Load(ContainerBuilder builder)
|
||||
|
|
@ -44,7 +46,7 @@ namespace PluralKit.Core
|
|||
var consoleTemplate = "[{Timestamp:HH:mm:ss.fff}] {Level:u3} {Message:lj}{NewLine}{Exception}";
|
||||
var outputTemplate = "[{Timestamp:yyyy-MM-dd HH:mm:ss.ffffff}] {Level:u3} {Message:lj}{NewLine}{Exception}";
|
||||
|
||||
var logCfg = new LoggerConfiguration()
|
||||
var logCfg = _cfg
|
||||
.Enrich.FromLogContext()
|
||||
.ConfigureForNodaTime(DateTimeZoneProviders.Tzdb)
|
||||
.Enrich.WithProperty("Component", _component)
|
||||
|
|
@ -53,6 +55,9 @@ namespace PluralKit.Core
|
|||
// Don't want App.Metrics/D#+ spam
|
||||
.MinimumLevel.Override("App.Metrics", LogEventLevel.Information)
|
||||
|
||||
// nor ASP.NET spam
|
||||
.MinimumLevel.Override("Microsoft", LogEventLevel.Information)
|
||||
|
||||
// Actual formatting for these is handled in ScalarFormatting
|
||||
.Destructure.AsScalar<SystemId>()
|
||||
.Destructure.AsScalar<MemberId>()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue