Change code to use Sentry client.

This commit is contained in:
Huo Yaoyuan 2019-11-12 21:12:38 +08:00
parent 1349289c0e
commit de732c6c24
3 changed files with 14 additions and 14 deletions

View File

@ -42,7 +42,7 @@ public class TestSceneOsuGame : OsuTestScene
private IReadOnlyList<Type> requiredGameDependencies => new[]
{
typeof(OsuGame),
typeof(RavenLogger),
typeof(SentryLogger),
typeof(OsuLogo),
typeof(IdleTracker),
typeof(OnScreenDisplay),

View File

@ -71,7 +71,7 @@ public class OsuGame : OsuGameBase, IKeyBindingHandler<GlobalAction>
[Cached]
private readonly ScreenshotManager screenshotManager = new ScreenshotManager();
protected RavenLogger RavenLogger;
protected SentryLogger RavenLogger;
public virtual Storage GetStorageForStableInstall() => null;
@ -110,7 +110,7 @@ public OsuGame(string[] args = null)
forwardLoggedErrorsToNotifications();
RavenLogger = new RavenLogger(this);
RavenLogger = new SentryLogger(this);
}
private void updateBlockingOverlayFade() =>

View File

@ -7,26 +7,26 @@
using System.Net;
using System.Threading.Tasks;
using osu.Framework.Logging;
using SharpRaven;
using SharpRaven.Data;
using Sentry;
namespace osu.Game.Utils
{
/// <summary>
/// Report errors to sentry.
/// </summary>
public class RavenLogger : IDisposable
public class SentryLogger : IDisposable
{
private readonly RavenClient raven = new RavenClient("https://5e342cd55f294edebdc9ad604d28bbd3@sentry.io/1255255");
private readonly List<Task> tasks = new List<Task>();
public RavenLogger(OsuGame game)
public SentryLogger(OsuGame game)
{
raven.Release = game.Version;
if (!game.IsDeployedBuild) return;
SentrySdk.Init(new SentryOptions
{
Dsn = new Dsn("https://5e342cd55f294edebdc9ad604d28bbd3@sentry.io/1255255"),
Release = game.Version
});
Exception lastException = null;
Logger.NewEntry += entry =>
@ -46,10 +46,10 @@ public RavenLogger(OsuGame game)
return;
lastException = exception;
queuePendingTask(raven.CaptureAsync(new SentryEvent(exception) { Message = entry.Message }));
SentrySdk.CaptureEvent(new SentryEvent(exception) { Message = entry.Message });
}
else
raven.AddTrail(new Breadcrumb(entry.Target.ToString(), BreadcrumbType.Navigation) { Message = entry.Message });
SentrySdk.AddBreadcrumb(category: entry.Target.ToString(), type: "navigation", message: entry.Message);
};
}
@ -93,7 +93,7 @@ private void queuePendingTask(Task<string> task)
#region Disposal
~RavenLogger()
~SentryLogger()
{
Dispose(false);
}