mirror of
https://github.com/ppy/osu.git
synced 2025-02-15 08:13:15 +08:00
Change to use instance API of sentry.
This commit is contained in:
parent
6ae6603ded
commit
8a1276db3a
@ -14,17 +14,21 @@ namespace osu.Game.Utils
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public class SentryLogger : IDisposable
|
public class SentryLogger : IDisposable
|
||||||
{
|
{
|
||||||
private IDisposable sentry;
|
private SentryClient sentry;
|
||||||
|
private Scope sentryScope;
|
||||||
|
|
||||||
public SentryLogger(OsuGame game)
|
public SentryLogger(OsuGame game)
|
||||||
{
|
{
|
||||||
if (!game.IsDeployedBuild) return;
|
if (!game.IsDeployedBuild) return;
|
||||||
|
|
||||||
sentry = SentrySdk.Init(new SentryOptions
|
var options = new SentryOptions
|
||||||
{
|
{
|
||||||
Dsn = new Dsn("https://5e342cd55f294edebdc9ad604d28bbd3@sentry.io/1255255"),
|
Dsn = new Dsn("https://5e342cd55f294edebdc9ad604d28bbd3@sentry.io/1255255"),
|
||||||
Release = game.Version
|
Release = game.Version
|
||||||
});
|
};
|
||||||
|
sentry = new SentryClient(options);
|
||||||
|
sentryScope = new Scope(options);
|
||||||
|
|
||||||
Exception lastException = null;
|
Exception lastException = null;
|
||||||
|
|
||||||
Logger.NewEntry += entry =>
|
Logger.NewEntry += entry =>
|
||||||
@ -44,10 +48,10 @@ namespace osu.Game.Utils
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
lastException = exception;
|
lastException = exception;
|
||||||
SentrySdk.CaptureEvent(new SentryEvent(exception) { Message = entry.Message });
|
sentry.CaptureEvent(new SentryEvent(exception) { Message = entry.Message }, sentryScope);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
SentrySdk.AddBreadcrumb(category: entry.Target.ToString(), type: "navigation", message: entry.Message);
|
sentryScope.AddBreadcrumb(DateTimeOffset.Now, entry.Message, entry.Target.ToString(), "navigation");
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -102,6 +106,7 @@ namespace osu.Game.Utils
|
|||||||
isDisposed = true;
|
isDisposed = true;
|
||||||
sentry?.Dispose();
|
sentry?.Dispose();
|
||||||
sentry = null;
|
sentry = null;
|
||||||
|
sentryScope = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
Loading…
Reference in New Issue
Block a user