diff options
author | Ac_K <Acoustik666@gmail.com> | 2023-01-11 23:27:26 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-01-11 23:27:26 +0100 |
commit | 70638340b30d0e9769224df770aa8817b5598793 (patch) | |
tree | e0afd427f4a96dc516493351f1778b50e8339a3d | |
parent | 4b495f3333c26b530710bf5c4d95870afd1f9570 (diff) |
Ava UI: Move Ava logging to Logger.Debug (#4255)1.1.542
* 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
-rw-r--r-- | Ryujinx.Ava/UI/Helpers/LoggerAdapter.cs | 34 |
1 files changed, 19 insertions, 15 deletions
diff --git a/Ryujinx.Ava/UI/Helpers/LoggerAdapter.cs b/Ryujinx.Ava/UI/Helpers/LoggerAdapter.cs index ba251f60..bb9681e2 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<T0>(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<T0, T1>(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<T0, T1, T2>(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); |