Merge branch 'master' into better-notification-delays

This commit is contained in:
Dan Balasescu
2017-12-27 23:26:57 +09:00
committed by GitHub
38 changed files with 179 additions and 72 deletions

View File

@ -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;
@ -222,15 +223,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);
@ -307,6 +300,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)