mirror of
https://github.com/ppy/osu.git
synced 2024-11-12 04:49:40 +08:00
Merge pull request #2848 from peppy/notification-usability
Improve log to notification forwarding
This commit is contained in:
commit
91af960200
@ -101,6 +101,8 @@ namespace osu.Game
|
|||||||
public OsuGame(string[] args = null)
|
public OsuGame(string[] args = null)
|
||||||
{
|
{
|
||||||
this.args = args;
|
this.args = args;
|
||||||
|
|
||||||
|
forwardLoggedErrorsToNotifications();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void ToggleSettings() => settings.ToggleVisibility();
|
public void ToggleSettings() => settings.ToggleVisibility();
|
||||||
@ -305,8 +307,6 @@ namespace osu.Game
|
|||||||
Depth = -6,
|
Depth = -6,
|
||||||
}, overlayContent.Add);
|
}, overlayContent.Add);
|
||||||
|
|
||||||
forwardLoggedErrorsToNotifications();
|
|
||||||
|
|
||||||
dependencies.Cache(settings);
|
dependencies.Cache(settings);
|
||||||
dependencies.Cache(onscreenDisplay);
|
dependencies.Cache(onscreenDisplay);
|
||||||
dependencies.Cache(social);
|
dependencies.Cache(social);
|
||||||
@ -394,31 +394,40 @@ namespace osu.Game
|
|||||||
|
|
||||||
private void forwardLoggedErrorsToNotifications()
|
private void forwardLoggedErrorsToNotifications()
|
||||||
{
|
{
|
||||||
int recentErrorCount = 0;
|
int recentLogCount = 0;
|
||||||
|
|
||||||
const double debounce = 5000;
|
const double debounce = 5000;
|
||||||
|
|
||||||
Logger.NewEntry += entry =>
|
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,
|
Icon = entry.Level == LogLevel.Important ? FontAwesome.fa_exclamation_circle : FontAwesome.fa_bomb,
|
||||||
Text = (recentErrorCount == 0 ? entry.Message : "Subsequent errors occurred and have been logged.") + "\nClick to view log files.",
|
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 = () =>
|
Activated = () =>
|
||||||
{
|
{
|
||||||
Host.Storage.GetStorageForDirectory("logs").OpenInNativeExplorer();
|
Host.Storage.GetStorageForDirectory("logs").OpenInNativeExplorer();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
});
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
Interlocked.Increment(ref recentErrorCount);
|
Interlocked.Increment(ref recentLogCount);
|
||||||
|
Scheduler.AddDelayed(() => Interlocked.Decrement(ref recentLogCount), debounce);
|
||||||
Scheduler.AddDelayed(() => Interlocked.Decrement(ref recentErrorCount), debounce);
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -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),
|
Colour = OsuColour.Gray(128),
|
||||||
AutoSizeAxes = Axes.Y,
|
AutoSizeAxes = Axes.Y,
|
||||||
|
Loading…
Reference in New Issue
Block a user