WPF: Update sentry config

This commit is contained in:
Genteure 2021-05-02 21:02:33 +08:00
parent 1eb71c66e0
commit b931e24523
2 changed files with 15 additions and 6 deletions

View File

@ -466,12 +466,15 @@ namespace BililiveRecorder.Core
{ {
_ = Task.Run(async () => _ = Task.Run(async () =>
{ {
// 定时主动检查不需要错误重试 try
{
// 定时主动检查不需要错误重试
await this.FetchRoomInfoAsync().ConfigureAwait(false);
await this.FetchRoomInfoAsync().ConfigureAwait(false); if (this.Streaming && this.AutoRecordForThisSession && this.RoomConfig.AutoRecord)
this.CreateAndStartNewRecordTask();
if (this.Streaming && this.AutoRecordForThisSession && this.RoomConfig.AutoRecord) }
this.CreateAndStartNewRecordTask(); catch (Exception) { }
}); });
} }
} }

View File

@ -38,6 +38,7 @@ namespace BililiveRecorder.WPF
levelSwitchConsole = new LoggingLevelSwitch(Serilog.Events.LogEventLevel.Error); levelSwitchConsole = new LoggingLevelSwitch(Serilog.Events.LogEventLevel.Error);
logger = BuildLogger(); logger = BuildLogger();
AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException; AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException;
TaskScheduler.UnobservedTaskException += TaskScheduler_UnobservedTaskException;
Log.Logger = logger; Log.Logger = logger;
SentrySdk.ConfigureScope(s => SentrySdk.ConfigureScope(s =>
{ {
@ -153,9 +154,10 @@ namespace BililiveRecorder.WPF
.WriteTo.File(new CompactJsonFormatter(), "./logs/bilirec.txt", shared: true, rollingInterval: RollingInterval.Day, rollOnFileSizeLimit: true) .WriteTo.File(new CompactJsonFormatter(), "./logs/bilirec.txt", shared: true, rollingInterval: RollingInterval.Day, rollOnFileSizeLimit: true)
.WriteTo.Sentry(o => .WriteTo.Sentry(o =>
{ {
o.Dsn = "https://7c6c5da3140543809661813aaa836207@o210546.ingest.sentry.io/5556540"; o.Dsn = "https://ecd9c92010ad47e7a787bb8fc47281e3@o210546.ingest.sentry.io/5556540";
o.DisableAppDomainUnhandledExceptionCapture(); o.DisableAppDomainUnhandledExceptionCapture();
o.DisableTaskUnobservedTaskExceptionCapture();
o.AddExceptionFilterForType<System.Net.Http.HttpRequestException>(); o.AddExceptionFilterForType<System.Net.Http.HttpRequestException>();
o.MinimumBreadcrumbLevel = Serilog.Events.LogEventLevel.Debug; o.MinimumBreadcrumbLevel = Serilog.Events.LogEventLevel.Debug;
@ -179,6 +181,10 @@ namespace BililiveRecorder.WPF
logger.Fatal(ex, "Unhandled exception from Application.UnhandledException"); logger.Fatal(ex, "Unhandled exception from Application.UnhandledException");
} }
[HandleProcessCorruptedStateExceptions, SecurityCritical]
private static void TaskScheduler_UnobservedTaskException(object sender, UnobservedTaskExceptionEventArgs e) =>
logger.Error(e.Exception, "Unobserved exception from TaskScheduler.UnobservedTaskException");
[HandleProcessCorruptedStateExceptions, SecurityCritical] [HandleProcessCorruptedStateExceptions, SecurityCritical]
private static void App_DispatcherUnhandledException(object sender, DispatcherUnhandledExceptionEventArgs e) => private static void App_DispatcherUnhandledException(object sender, DispatcherUnhandledExceptionEventArgs e) =>
logger.Fatal(e.Exception, "Unhandled exception from AppDomain.DispatcherUnhandledException"); logger.Fatal(e.Exception, "Unhandled exception from AppDomain.DispatcherUnhandledException");