1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-12 03:57:25 +08:00

Merge pull request #2848 from peppy/notification-usability

Improve log to notification forwarding
This commit is contained in:
Dean Herbert 2018-06-21 20:04:00 +09:00 committed by GitHub
commit 91af960200
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 22 additions and 13 deletions

View File

@ -101,6 +101,8 @@ namespace osu.Game
public OsuGame(string[] args = null)
{
this.args = args;
forwardLoggedErrorsToNotifications();
}
public void ToggleSettings() => settings.ToggleVisibility();
@ -305,8 +307,6 @@ namespace osu.Game
Depth = -6,
}, overlayContent.Add);
forwardLoggedErrorsToNotifications();
dependencies.Cache(settings);
dependencies.Cache(onscreenDisplay);
dependencies.Cache(social);
@ -394,31 +394,40 @@ namespace osu.Game
private void forwardLoggedErrorsToNotifications()
{
int recentErrorCount = 0;
int recentLogCount = 0;
const double debounce = 5000;
Logger.NewEntry += entry =>
{
if (entry.Level < LogLevel.Error || entry.Target == null) return;
if (entry.Level < LogLevel.Important || entry.Target == null) return;
if (recentErrorCount < 2)
const int short_term_display_limit = 3;
if (recentLogCount < short_term_display_limit)
{
notifications.Post(new SimpleNotification
Schedule(() => 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.",
Icon = entry.Level == LogLevel.Important ? FontAwesome.fa_exclamation_circle : FontAwesome.fa_bomb,
Text = entry.Message,
}));
}
else if (recentLogCount == short_term_display_limit)
{
Schedule(() => notifications.Post(new SimpleNotification
{
Icon = FontAwesome.fa_ellipsis_h,
Text = "Subsequent messages have been logged. Click to view log files.",
Activated = () =>
{
Host.Storage.GetStorageForDirectory("logs").OpenInNativeExplorer();
return true;
}
});
}));
}
Interlocked.Increment(ref recentErrorCount);
Scheduler.AddDelayed(() => Interlocked.Decrement(ref recentErrorCount), debounce);
Interlocked.Increment(ref recentLogCount);
Scheduler.AddDelayed(() => Interlocked.Decrement(ref recentLogCount), debounce);
};
}

View File

@ -59,7 +59,7 @@ namespace osu.Game.Overlays.Notifications
}
});
Content.Add(textDrawable = new OsuTextFlowContainer(t => t.TextSize = 16)
Content.Add(textDrawable = new OsuTextFlowContainer(t => t.TextSize = 14)
{
Colour = OsuColour.Gray(128),
AutoSizeAxes = Axes.Y,