From 70638340b30d0e9769224df770aa8817b5598793 Mon Sep 17 00:00:00 2001 From: Ac_K Date: Wed, 11 Jan 2023 23:27:26 +0100 Subject: [PATCH] Ava UI: Move Ava logging to Logger.Debug (#4255) * Ava: Move Ava logging to Logger.Debug Since #4231 we currently redirect Avalonia logs to our Logger, which is pretty nice. But since it uses our Logging level too, it now leads to a massive flood in our Log files. To avoid that, I've included all `AvaLogLevel` to the log message, and make all Ava Logs using `Logger.Debug`. * Logs errors to Error and other to Debug * missing level * keep var --- Ryujinx.Ava/UI/Helpers/LoggerAdapter.cs | 34 ++++++++++++++----------- 1 file changed, 19 insertions(+), 15 deletions(-) diff --git a/Ryujinx.Ava/UI/Helpers/LoggerAdapter.cs b/Ryujinx.Ava/UI/Helpers/LoggerAdapter.cs index ba251f6040..bb9681e225 100644 --- a/Ryujinx.Ava/UI/Helpers/LoggerAdapter.cs +++ b/Ryujinx.Ava/UI/Helpers/LoggerAdapter.cs @@ -4,9 +4,9 @@ using System.Text; namespace Ryujinx.Ava.UI.Helpers { - using AvaLogger = Avalonia.Logging.Logger; + using AvaLogger = Avalonia.Logging.Logger; using AvaLogLevel = Avalonia.Logging.LogEventLevel; - using RyuLogger = Ryujinx.Common.Logging.Logger; + using RyuLogger = Ryujinx.Common.Logging.Logger; using RyuLogClass = Ryujinx.Common.Logging.LogClass; internal class LoggerAdapter : Avalonia.Logging.ILogSink @@ -20,12 +20,12 @@ namespace Ryujinx.Ava.UI.Helpers { return level switch { - AvaLogLevel.Verbose => RyuLogger.Trace, - AvaLogLevel.Debug => RyuLogger.Debug, - AvaLogLevel.Information => RyuLogger.Info, - AvaLogLevel.Warning => RyuLogger.Warning, - AvaLogLevel.Error => RyuLogger.Error, - AvaLogLevel.Fatal => RyuLogger.Notice, + AvaLogLevel.Verbose => RyuLogger.Debug, + AvaLogLevel.Debug => RyuLogger.Debug, + AvaLogLevel.Information => RyuLogger.Debug, + AvaLogLevel.Warning => RyuLogger.Debug, + AvaLogLevel.Error => RyuLogger.Error, + AvaLogLevel.Fatal => RyuLogger.Error, _ => throw new ArgumentOutOfRangeException(nameof(level), level, null) }; } @@ -37,34 +37,38 @@ namespace Ryujinx.Ava.UI.Helpers public void Log(AvaLogLevel level, string area, object source, string messageTemplate) { - GetLog(level)?.PrintMsg(RyuLogClass.Ui, Format(area, messageTemplate, source, null)); + GetLog(level)?.PrintMsg(RyuLogClass.Ui, Format(level, area, messageTemplate, source, null)); } public void Log(AvaLogLevel level, string area, object source, string messageTemplate, T0 propertyValue0) { - GetLog(level)?.PrintMsg(RyuLogClass.Ui, Format(area, messageTemplate, source, new object[] { propertyValue0 })); + GetLog(level)?.PrintMsg(RyuLogClass.Ui, Format(level, area, messageTemplate, source, new object[] { propertyValue0 })); } public void Log(AvaLogLevel level, string area, object source, string messageTemplate, T0 propertyValue0, T1 propertyValue1) { - GetLog(level)?.PrintMsg(RyuLogClass.Ui, Format(area, messageTemplate, source, new object[] { propertyValue0, propertyValue1 })); + GetLog(level)?.PrintMsg(RyuLogClass.Ui, Format(level, area, messageTemplate, source, new object[] { propertyValue0, propertyValue1 })); } public void Log(AvaLogLevel level, string area, object source, string messageTemplate, T0 propertyValue0, T1 propertyValue1, T2 propertyValue2) { - GetLog(level)?.PrintMsg(RyuLogClass.Ui, Format(area, messageTemplate, source, new object[] { propertyValue0, propertyValue1, propertyValue2 })); + GetLog(level)?.PrintMsg(RyuLogClass.Ui, Format(level, area, messageTemplate, source, new object[] { propertyValue0, propertyValue1, propertyValue2 })); } public void Log(AvaLogLevel level, string area, object source, string messageTemplate, params object[] propertyValues) { - GetLog(level)?.PrintMsg(RyuLogClass.Ui, Format(area, messageTemplate, source, propertyValues)); + GetLog(level)?.PrintMsg(RyuLogClass.Ui, Format(level, area, messageTemplate, source, propertyValues)); } - private static string Format(string area, string template, object source, object[] v) + private static string Format(AvaLogLevel level, string area, string template, object source, object[] v) { var result = new StringBuilder(); var r = new CharacterReader(template.AsSpan()); - var i = 0; + int i = 0; + + result.Append('['); + result.Append(level); + result.Append("] "); result.Append('['); result.Append(area);