mirror of
https://github.com/ppy/osu.git
synced 2024-12-15 01:43:20 +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[]
|
private IReadOnlyList<Type> requiredGameDependencies => new[]
|
||||||
{
|
{
|
||||||
typeof(OsuGame),
|
typeof(OsuGame),
|
||||||
typeof(RavenLogger),
|
typeof(SentryLogger),
|
||||||
typeof(OsuLogo),
|
typeof(OsuLogo),
|
||||||
typeof(IdleTracker),
|
typeof(IdleTracker),
|
||||||
typeof(OnScreenDisplay),
|
typeof(OnScreenDisplay),
|
||||||
|
@ -71,7 +71,7 @@ namespace osu.Game
|
|||||||
[Cached]
|
[Cached]
|
||||||
private readonly ScreenshotManager screenshotManager = new ScreenshotManager();
|
private readonly ScreenshotManager screenshotManager = new ScreenshotManager();
|
||||||
|
|
||||||
protected RavenLogger RavenLogger;
|
protected SentryLogger SentryLogger;
|
||||||
|
|
||||||
public virtual Storage GetStorageForStableInstall() => null;
|
public virtual Storage GetStorageForStableInstall() => null;
|
||||||
|
|
||||||
@ -110,7 +110,7 @@ namespace osu.Game
|
|||||||
|
|
||||||
forwardLoggedErrorsToNotifications();
|
forwardLoggedErrorsToNotifications();
|
||||||
|
|
||||||
RavenLogger = new RavenLogger(this);
|
SentryLogger = new SentryLogger(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateBlockingOverlayFade() =>
|
private void updateBlockingOverlayFade() =>
|
||||||
@ -166,7 +166,7 @@ namespace osu.Game
|
|||||||
|
|
||||||
dependencies.CacheAs(this);
|
dependencies.CacheAs(this);
|
||||||
|
|
||||||
dependencies.Cache(RavenLogger);
|
dependencies.Cache(SentryLogger);
|
||||||
|
|
||||||
dependencies.Cache(osuLogo = new OsuLogo { Alpha = 0 });
|
dependencies.Cache(osuLogo = new OsuLogo { Alpha = 0 });
|
||||||
|
|
||||||
@ -486,7 +486,7 @@ namespace osu.Game
|
|||||||
protected override void Dispose(bool isDisposing)
|
protected override void Dispose(bool isDisposing)
|
||||||
{
|
{
|
||||||
base.Dispose(isDisposing);
|
base.Dispose(isDisposing);
|
||||||
RavenLogger.Dispose();
|
SentryLogger.Dispose();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void LoadComplete()
|
protected override void LoadComplete()
|
||||||
|
@ -2,31 +2,34 @@
|
|||||||
// See the LICENCE file in the repository root for full licence text.
|
// See the LICENCE file in the repository root for full licence text.
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Net;
|
using System.Net;
|
||||||
using System.Threading.Tasks;
|
|
||||||
using osu.Framework.Logging;
|
using osu.Framework.Logging;
|
||||||
using SharpRaven;
|
using Sentry;
|
||||||
using SharpRaven.Data;
|
|
||||||
|
|
||||||
namespace osu.Game.Utils
|
namespace osu.Game.Utils
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Report errors to sentry.
|
/// Report errors to sentry.
|
||||||
/// </summary>
|
/// </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 SentryLogger(OsuGame game)
|
||||||
|
|
||||||
public RavenLogger(OsuGame game)
|
|
||||||
{
|
{
|
||||||
raven.Release = game.Version;
|
|
||||||
|
|
||||||
if (!game.IsDeployedBuild) return;
|
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;
|
Exception lastException = null;
|
||||||
|
|
||||||
Logger.NewEntry += entry =>
|
Logger.NewEntry += entry =>
|
||||||
@ -46,10 +49,10 @@ namespace osu.Game.Utils
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
lastException = exception;
|
lastException = exception;
|
||||||
queuePendingTask(raven.CaptureAsync(new SentryEvent(exception) { Message = entry.Message }));
|
sentry.CaptureEvent(new SentryEvent(exception) { Message = entry.Message }, sentryScope);
|
||||||
}
|
}
|
||||||
else
|
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;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void queuePendingTask(Task<string> task)
|
|
||||||
{
|
|
||||||
lock (tasks) tasks.Add(task);
|
|
||||||
task.ContinueWith(_ =>
|
|
||||||
{
|
|
||||||
lock (tasks)
|
|
||||||
tasks.Remove(task);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
#region Disposal
|
#region Disposal
|
||||||
|
|
||||||
~RavenLogger()
|
~SentryLogger()
|
||||||
{
|
{
|
||||||
Dispose(false);
|
Dispose(false);
|
||||||
}
|
}
|
||||||
@ -112,7 +105,9 @@ namespace osu.Game.Utils
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
isDisposed = true;
|
isDisposed = true;
|
||||||
lock (tasks) Task.WaitAll(tasks.ToArray(), 5000);
|
sentry?.Dispose();
|
||||||
|
sentry = null;
|
||||||
|
sentryScope = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
@ -22,9 +22,9 @@
|
|||||||
<PackageReference Include="Newtonsoft.Json" Version="12.0.3" />
|
<PackageReference Include="Newtonsoft.Json" Version="12.0.3" />
|
||||||
<PackageReference Include="ppy.osu.Game.Resources" Version="2019.1010.0" />
|
<PackageReference Include="ppy.osu.Game.Resources" Version="2019.1010.0" />
|
||||||
<PackageReference Include="ppy.osu.Framework" Version="2019.1121.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="SharpCompress" Version="0.24.0" />
|
||||||
<PackageReference Include="NUnit" Version="3.12.0" />
|
<PackageReference Include="NUnit" Version="3.12.0" />
|
||||||
<PackageReference Include="SharpRaven" Version="2.4.0" />
|
|
||||||
<PackageReference Include="System.ComponentModel.Annotations" Version="4.6.0" />
|
<PackageReference Include="System.ComponentModel.Annotations" Version="4.6.0" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
</Project>
|
</Project>
|
||||||
|
Loading…
Reference in New Issue
Block a user