mirror of
https://github.com/ppy/osu
synced 2024-12-14 02:46:27 +00:00
Reduce notification output when exceptions are encountered
This commit is contained in:
parent
45e4c09cb8
commit
320a6b0480
@ -220,15 +220,7 @@ namespace osu.Game
|
|||||||
Depth = -6,
|
Depth = -6,
|
||||||
}, overlayContent.Add);
|
}, overlayContent.Add);
|
||||||
|
|
||||||
Logger.NewEntry += entry =>
|
forwardLoggedErrorsToNotifications();
|
||||||
{
|
|
||||||
if (entry.Level < LogLevel.Important) return;
|
|
||||||
|
|
||||||
notifications.Post(new SimpleNotification
|
|
||||||
{
|
|
||||||
Text = $@"{entry.Level}: {entry.Message}"
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
dependencies.Cache(settings);
|
dependencies.Cache(settings);
|
||||||
dependencies.Cache(social);
|
dependencies.Cache(social);
|
||||||
@ -290,6 +282,36 @@ namespace osu.Game
|
|||||||
Cursor.State = Visibility.Hidden;
|
Cursor.State = Visibility.Hidden;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void forwardLoggedErrorsToNotifications()
|
||||||
|
{
|
||||||
|
int recentErrorCount = 0;
|
||||||
|
|
||||||
|
const double debounce = 5000;
|
||||||
|
|
||||||
|
Logger.NewEntry += entry =>
|
||||||
|
{
|
||||||
|
if (entry.Level < LogLevel.Error || entry.Target == null) return;
|
||||||
|
|
||||||
|
if (recentErrorCount < 2)
|
||||||
|
{
|
||||||
|
notifications.Post(new SimpleNotification
|
||||||
|
{
|
||||||
|
Icon = FontAwesome.fa_bomb,
|
||||||
|
Text = (recentErrorCount == 0 ? entry.Message : "Subsequent errors occurred and have been logged.") + "\nClick to view log files.",
|
||||||
|
Activated = () =>
|
||||||
|
{
|
||||||
|
Host.Storage.GetStorageForDirectory("logs").OpenInNativeExplorer();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
recentErrorCount++;
|
||||||
|
|
||||||
|
Scheduler.AddDelayed(() => recentErrorCount--, debounce);
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
private Task asyncLoadStream;
|
private Task asyncLoadStream;
|
||||||
|
|
||||||
private void loadComponentSingleFile<T>(T d, Action<T> add)
|
private void loadComponentSingleFile<T>(T d, Action<T> add)
|
||||||
|
Loading…
Reference in New Issue
Block a user