Add sentry logging

This commit is contained in:
Dean Herbert
2018-08-03 19:25:55 +09:00
parent 1ed6b23306
commit 2ea90ef98a
5 changed files with 116 additions and 1 deletions

View File

@ -4,7 +4,10 @@
using System;
using System.IO;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using osu.Framework;
using osu.Framework.Logging;
using osu.Framework.Platform;
using osu.Game.IPC;
@ -20,6 +23,8 @@ namespace osu.Desktop
using (DesktopGameHost host = Host.GetSuitableHost(@"osu", true))
{
host.ExceptionThrown += handleException;
if (!host.IsPrimaryInstance)
{
var importer = new ArchiveImportIPCChannel(host);
@ -45,5 +50,22 @@ namespace osu.Desktop
return 0;
}
}
private static int allowableExceptions = 1;
/// <summary>
/// Allow a maximum of one unhandled exception, per second of execution.
/// </summary>
/// <param name="arg"></param>
/// <returns></returns>
private static bool handleException(Exception arg)
{
bool continueExecution = Interlocked.Decrement(ref allowableExceptions) >= 0;
Logger.Log($"Unhandled exception has been {(continueExecution ? "allowed" : "denied")} with {allowableExceptions} more allowable exceptions.");
Task.Delay(1000).ContinueWith(_ => Interlocked.Increment(ref allowableExceptions));
return Interlocked.Decrement(ref allowableExceptions) >= 0;
}
}
}