mirror of
https://github.com/ppy/osu.git
synced 2024-12-14 23:12:56 +08:00
Handle SharpRaven deprecation (#6824)
Handle SharpRaven deprecation Co-authored-by: Dean Herbert <pe@ppy.sh>
This commit is contained in:
commit
561417e9dc
@ -42,7 +42,7 @@ namespace osu.Game.Tests.Visual
|
||||
private IReadOnlyList<Type> requiredGameDependencies => new[]
|
||||
{
|
||||
typeof(OsuGame),
|
||||
typeof(RavenLogger),
|
||||
typeof(SentryLogger),
|
||||
typeof(OsuLogo),
|
||||
typeof(IdleTracker),
|
||||
typeof(OnScreenDisplay),
|
||||
|
@ -71,7 +71,7 @@ namespace osu.Game
|
||||
[Cached]
|
||||
private readonly ScreenshotManager screenshotManager = new ScreenshotManager();
|
||||
|
||||
protected RavenLogger RavenLogger;
|
||||
protected SentryLogger SentryLogger;
|
||||
|
||||
public virtual Storage GetStorageForStableInstall() => null;
|
||||
|
||||
@ -110,7 +110,7 @@ namespace osu.Game
|
||||
|
||||
forwardLoggedErrorsToNotifications();
|
||||
|
||||
RavenLogger = new RavenLogger(this);
|
||||
SentryLogger = new SentryLogger(this);
|
||||
}
|
||||
|
||||
private void updateBlockingOverlayFade() =>
|
||||
@ -166,7 +166,7 @@ namespace osu.Game
|
||||
|
||||
dependencies.CacheAs(this);
|
||||
|
||||
dependencies.Cache(RavenLogger);
|
||||
dependencies.Cache(SentryLogger);
|
||||
|
||||
dependencies.Cache(osuLogo = new OsuLogo { Alpha = 0 });
|
||||
|
||||
@ -486,7 +486,7 @@ namespace osu.Game
|
||||
protected override void Dispose(bool isDisposing)
|
||||
{
|
||||
base.Dispose(isDisposing);
|
||||
RavenLogger.Dispose();
|
||||
SentryLogger.Dispose();
|
||||
}
|
||||
|
||||
protected override void LoadComplete()
|
||||
|
@ -2,31 +2,34 @@
|
||||
// See the LICENCE file in the repository root for full licence text.
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
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 SentryClient sentry;
|
||||
private Scope sentryScope;
|
||||
|
||||
private readonly List<Task> tasks = new List<Task>();
|
||||
|
||||
public RavenLogger(OsuGame game)
|
||||
public SentryLogger(OsuGame game)
|
||||
{
|
||||
raven.Release = game.Version;
|
||||
|
||||
if (!game.IsDeployedBuild) return;
|
||||
|
||||
var options = new SentryOptions
|
||||
{
|
||||
Dsn = new Dsn("https://5e342cd55f294edebdc9ad604d28bbd3@sentry.io/1255255"),
|
||||
Release = game.Version
|
||||
};
|
||||
|
||||
sentry = new SentryClient(options);
|
||||
sentryScope = new Scope(options);
|
||||
|
||||
Exception lastException = null;
|
||||
|
||||
Logger.NewEntry += entry =>
|
||||
@ -46,10 +49,10 @@ namespace osu.Game.Utils
|
||||
return;
|
||||
|
||||
lastException = exception;
|
||||
queuePendingTask(raven.CaptureAsync(new SentryEvent(exception) { Message = entry.Message }));
|
||||
sentry.CaptureEvent(new SentryEvent(exception) { Message = entry.Message }, sentryScope);
|
||||
}
|
||||
else
|
||||
raven.AddTrail(new Breadcrumb(entry.Target.ToString(), BreadcrumbType.Navigation) { Message = entry.Message });
|
||||
sentryScope.AddBreadcrumb(DateTimeOffset.Now, entry.Message, entry.Target.ToString(), "navigation");
|
||||
};
|
||||
}
|
||||
|
||||
@ -81,19 +84,9 @@ namespace osu.Game.Utils
|
||||
return true;
|
||||
}
|
||||
|
||||
private void queuePendingTask(Task<string> task)
|
||||
{
|
||||
lock (tasks) tasks.Add(task);
|
||||
task.ContinueWith(_ =>
|
||||
{
|
||||
lock (tasks)
|
||||
tasks.Remove(task);
|
||||
});
|
||||
}
|
||||
|
||||
#region Disposal
|
||||
|
||||
~RavenLogger()
|
||||
~SentryLogger()
|
||||
{
|
||||
Dispose(false);
|
||||
}
|
||||
@ -112,7 +105,9 @@ namespace osu.Game.Utils
|
||||
return;
|
||||
|
||||
isDisposed = true;
|
||||
lock (tasks) Task.WaitAll(tasks.ToArray(), 5000);
|
||||
sentry?.Dispose();
|
||||
sentry = null;
|
||||
sentryScope = null;
|
||||
}
|
||||
|
||||
#endregion
|
@ -22,9 +22,9 @@
|
||||
<PackageReference Include="Newtonsoft.Json" Version="12.0.3" />
|
||||
<PackageReference Include="ppy.osu.Game.Resources" Version="2019.1010.0" />
|
||||
<PackageReference Include="ppy.osu.Framework" Version="2019.1121.0" />
|
||||
<PackageReference Include="Sentry" Version="1.2.0" />
|
||||
<PackageReference Include="SharpCompress" Version="0.24.0" />
|
||||
<PackageReference Include="NUnit" Version="3.12.0" />
|
||||
<PackageReference Include="SharpRaven" Version="2.4.0" />
|
||||
<PackageReference Include="System.ComponentModel.Annotations" Version="4.6.0" />
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
|
Loading…
Reference in New Issue
Block a user