1
0
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:
Dean Herbert 2019-11-21 23:11:54 +09:00 committed by GitHub
commit 561417e9dc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 26 additions and 31 deletions

View File

@ -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),

View File

@ -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()

View File

@ -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

View File

@ -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>