mirror of
https://github.com/ppy/osu.git
synced 2024-12-14 09:32:55 +08:00
Merge pull request #1745 from peppy/notification-verbosity
Rate limit logged errors displayed as notifications
This commit is contained in:
commit
9841fd6cd6
@ -1,6 +1,7 @@
|
||||
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
|
||||
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using osu.Framework.Graphics;
|
||||
@ -16,6 +17,15 @@ namespace osu.Game.Tests.Visual
|
||||
private readonly NotificationOverlay manager;
|
||||
private readonly List<ProgressNotification> progressingNotifications = new List<ProgressNotification>();
|
||||
|
||||
public override IReadOnlyList<Type> RequiredTypes => new[]
|
||||
{
|
||||
typeof(Notification),
|
||||
typeof(ProgressNotification),
|
||||
typeof(ProgressCompletionNotification),
|
||||
typeof(SimpleNotification),
|
||||
typeof(IHasCompletionTarget),
|
||||
};
|
||||
|
||||
public TestCaseNotificationOverlay()
|
||||
{
|
||||
progressingNotifications.Clear();
|
||||
|
@ -16,6 +16,7 @@ using osu.Game.Screens;
|
||||
using osu.Game.Screens.Menu;
|
||||
using OpenTK;
|
||||
using System.Linq;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using osu.Framework.Input.Bindings;
|
||||
using osu.Framework.Platform;
|
||||
@ -220,15 +221,7 @@ namespace osu.Game
|
||||
Depth = -6,
|
||||
}, overlayContent.Add);
|
||||
|
||||
Logger.NewEntry += entry =>
|
||||
{
|
||||
if (entry.Level < LogLevel.Important) return;
|
||||
|
||||
notifications.Post(new SimpleNotification
|
||||
{
|
||||
Text = $@"{entry.Level}: {entry.Message}"
|
||||
});
|
||||
};
|
||||
forwardLoggedErrorsToNotifications();
|
||||
|
||||
dependencies.Cache(settings);
|
||||
dependencies.Cache(social);
|
||||
@ -290,6 +283,36 @@ namespace osu.Game
|
||||
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;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
Interlocked.Increment(ref recentErrorCount);
|
||||
|
||||
Scheduler.AddDelayed(() => Interlocked.Decrement(ref recentErrorCount), debounce);
|
||||
};
|
||||
}
|
||||
|
||||
private Task asyncLoadStream;
|
||||
|
||||
private void loadComponentSingleFile<T>(T d, Action<T> add)
|
||||
|
@ -177,8 +177,7 @@ namespace osu.Game
|
||||
}
|
||||
catch (MigrationFailedException e)
|
||||
{
|
||||
Logger.Log((e.InnerException ?? e).ToString(), LoggingTarget.Database, LogLevel.Error);
|
||||
Logger.Log("Migration failed! We'll be starting with a fresh database.", LoggingTarget.Database, LogLevel.Error);
|
||||
Logger.Error(e.InnerException ?? e, "Migration failed! We'll be starting with a fresh database.", LoggingTarget.Database);
|
||||
|
||||
// if we failed, let's delete the database and start fresh.
|
||||
// todo: we probably want a better (non-destructive) migrations/recovery process at a later point than this.
|
||||
|
@ -91,7 +91,6 @@ namespace osu.Game.Overlays.Notifications
|
||||
AutoSizeAxes = Axes.Y,
|
||||
Padding = new MarginPadding
|
||||
{
|
||||
Top = 5,
|
||||
Left = 45,
|
||||
Right = 30
|
||||
},
|
||||
|
@ -42,7 +42,7 @@ namespace osu.Game.Rulesets.Edit
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Logger.Log($"Could not load this beatmap sucessfully ({e})!", LoggingTarget.Runtime, LogLevel.Error);
|
||||
Logger.Error(e, "Could not load beatmap sucessfully!");
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -125,7 +125,7 @@ namespace osu.Game.Screens.Play
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Logger.Log($"Could not load this beatmap sucessfully ({e})!", LoggingTarget.Runtime, LogLevel.Error);
|
||||
Logger.Error(e, "Could not load beatmap sucessfully!");
|
||||
|
||||
//couldn't load, hard abort!
|
||||
Exit();
|
||||
|
Loading…
Reference in New Issue
Block a user