From faa654dbaf7cd5262c78c0961a5aa72b1ce8ac33 Mon Sep 17 00:00:00 2001 From: Mark Araujo <36304206+Pixxel123@users.noreply.github.com> Date: Tue, 13 Apr 2021 20:58:47 +0100 Subject: [PATCH] Improves logging to console. (#2146) * Restore removed text * Adds more items to logs: - Remove #1942 * Further removal of changes from #1942 * Removes hardcoded config state variables for logging - Adds Configuration logging * Decoupled logging from ReactiveObject - Event handler added to Configuration state to handle logging of value changes * Decoupled logging from ReactiveObject - Event handler added to Configuration state to handle logging of value changes --- .../Configuration/ConfigurationState.cs | 75 ++++++++++++------- Ryujinx.Common/Logging/LogClass.cs | 1 + Ryujinx.HLE/HOS/Horizon.cs | 3 - Ryujinx.HLE/Switch.cs | 6 -- Ryujinx/Ui/GLRenderer.cs | 3 - Ryujinx/Ui/Windows/SettingsWindow.cs | 10 +-- 6 files changed, 49 insertions(+), 49 deletions(-) diff --git a/Ryujinx.Common/Configuration/ConfigurationState.cs b/Ryujinx.Common/Configuration/ConfigurationState.cs index e257fa232..1e26b4f4a 100644 --- a/Ryujinx.Common/Configuration/ConfigurationState.cs +++ b/Ryujinx.Common/Configuration/ConfigurationState.cs @@ -155,16 +155,17 @@ namespace Ryujinx.Configuration public LoggerSection() { - EnableDebug = new ReactiveObject(); - EnableStub = new ReactiveObject(); - EnableInfo = new ReactiveObject(); - EnableWarn = new ReactiveObject(); - EnableError = new ReactiveObject(); - EnableGuest = new ReactiveObject(); - EnableFsAccessLog = new ReactiveObject(); - FilteredClasses = new ReactiveObject(); - EnableFileLog = new ReactiveObject(); - GraphicsDebugLevel = new ReactiveObject(); + EnableDebug = new ReactiveObject(); + EnableStub = new ReactiveObject(); + EnableInfo = new ReactiveObject(); + EnableWarn = new ReactiveObject(); + EnableError = new ReactiveObject(); + EnableGuest = new ReactiveObject(); + EnableFsAccessLog = new ReactiveObject(); + FilteredClasses = new ReactiveObject(); + EnableFileLog = new ReactiveObject(); + EnableFileLog.Event += static (sender, e) => LogValueChange(sender, e, nameof(EnableFileLog)); + GraphicsDebugLevel = new ReactiveObject(); } } @@ -230,17 +231,24 @@ namespace Ryujinx.Configuration public SystemSection() { - Language = new ReactiveObject(); - Region = new ReactiveObject(); - TimeZone = new ReactiveObject(); - SystemTimeOffset = new ReactiveObject(); - EnableDockedMode = new ReactiveObject(); - EnablePtc = new ReactiveObject(); - EnableFsIntegrityChecks = new ReactiveObject(); - FsGlobalAccessLogMode = new ReactiveObject(); - AudioBackend = new ReactiveObject(); - ExpandRam = new ReactiveObject(); - IgnoreMissingServices = new ReactiveObject(); + Language = new ReactiveObject(); + Region = new ReactiveObject(); + TimeZone = new ReactiveObject(); + SystemTimeOffset = new ReactiveObject(); + EnableDockedMode = new ReactiveObject(); + EnableDockedMode.Event += static (sender, e) => LogValueChange(sender, e, nameof(EnableDockedMode)); + EnablePtc = new ReactiveObject(); + EnablePtc.Event += static (sender, e) => LogValueChange(sender, e, nameof(EnablePtc)); + EnableFsIntegrityChecks = new ReactiveObject(); + EnableFsIntegrityChecks.Event += static (sender, e) => LogValueChange(sender, e, nameof(EnableFsIntegrityChecks)); + FsGlobalAccessLogMode = new ReactiveObject(); + FsGlobalAccessLogMode.Event += static (sender, e) => LogValueChange(sender, e, nameof(FsGlobalAccessLogMode)); + AudioBackend = new ReactiveObject(); + AudioBackend.Event += static (sender, e) => LogValueChange(sender, e, nameof(AudioBackend)); + ExpandRam = new ReactiveObject(); + ExpandRam.Event += static (sender, e) => LogValueChange(sender, e, nameof(ExpandRam)); + IgnoreMissingServices = new ReactiveObject(); + IgnoreMissingServices.Event += static (sender, e) => LogValueChange(sender, e, nameof(IgnoreMissingServices)); } } @@ -316,13 +324,19 @@ namespace Ryujinx.Configuration public GraphicsSection() { - ResScale = new ReactiveObject(); - ResScaleCustom = new ReactiveObject(); - MaxAnisotropy = new ReactiveObject(); - AspectRatio = new ReactiveObject(); - ShadersDumpPath = new ReactiveObject(); - EnableVsync = new ReactiveObject(); - EnableShaderCache = new ReactiveObject(); + ResScale = new ReactiveObject(); + ResScale.Event += static (sender, e) => LogValueChange(sender, e, nameof(ResScale)); + ResScaleCustom = new ReactiveObject(); + ResScaleCustom.Event += static (sender, e) => LogValueChange(sender, e, nameof(ResScaleCustom)); + MaxAnisotropy = new ReactiveObject(); + MaxAnisotropy.Event += static (sender, e) => LogValueChange(sender, e, nameof(MaxAnisotropy)); + AspectRatio = new ReactiveObject(); + AspectRatio.Event += static (sender, e) => LogValueChange(sender, e, nameof(AspectRatio)); + ShadersDumpPath = new ReactiveObject(); + EnableVsync = new ReactiveObject(); + EnableVsync.Event += static (sender, e) => LogValueChange(sender, e, nameof(EnableVsync)); + EnableShaderCache = new ReactiveObject(); + EnableShaderCache.Event += static (sender, e) => LogValueChange(sender, e, nameof(EnableShaderCache)); } } @@ -876,6 +890,11 @@ namespace Ryujinx.Configuration } } + private static void LogValueChange(object sender, ReactiveEventArgs eventArgs, string valueName) + { + Common.Logging.Logger.Info?.Print(LogClass.Configuration, $"{valueName} set to: {eventArgs.NewValue}"); + } + public static void Initialize() { if (Instance != null) diff --git a/Ryujinx.Common/Logging/LogClass.cs b/Ryujinx.Common/Logging/LogClass.cs index a6d9435e2..1597805c8 100644 --- a/Ryujinx.Common/Logging/LogClass.cs +++ b/Ryujinx.Common/Logging/LogClass.cs @@ -5,6 +5,7 @@ namespace Ryujinx.Common.Logging Application, Audio, AudioRenderer, + Configuration, Cpu, Font, Emulation, diff --git a/Ryujinx.HLE/HOS/Horizon.cs b/Ryujinx.HLE/HOS/Horizon.cs index f7fcad2aa..0f66192a7 100644 --- a/Ryujinx.HLE/HOS/Horizon.cs +++ b/Ryujinx.HLE/HOS/Horizon.cs @@ -9,7 +9,6 @@ using Ryujinx.Audio.Output; using Ryujinx.Audio.Renderer.Device; using Ryujinx.Audio.Renderer.Server; using Ryujinx.Common; -using Ryujinx.Common.Logging; using Ryujinx.Configuration; using Ryujinx.HLE.FileSystem.Content; using Ryujinx.HLE.HOS.Font; @@ -328,8 +327,6 @@ namespace Ryujinx.HLE.HOS // Reconfigure controllers Device.Hid.RefreshInputConfig(ConfigurationState.Instance.Hid.InputConfig.Value); - - Logger.Info?.Print(LogClass.Application, $"IsDocked toggled to: {State.DockedMode}"); } } diff --git a/Ryujinx.HLE/Switch.cs b/Ryujinx.HLE/Switch.cs index a36c006dc..b88bdbfe2 100644 --- a/Ryujinx.HLE/Switch.cs +++ b/Ryujinx.HLE/Switch.cs @@ -2,7 +2,6 @@ using LibHac.FsSystem; using Ryujinx.Audio.Backends.CompatLayer; using Ryujinx.Audio.Integration; using Ryujinx.Common; -using Ryujinx.Common.Logging; using Ryujinx.Configuration; using Ryujinx.Graphics.GAL; using Ryujinx.Graphics.Gpu; @@ -154,11 +153,6 @@ namespace Ryujinx.HLE // Configure controllers Hid.RefreshInputConfig(ConfigurationState.Instance.Hid.InputConfig.Value); ConfigurationState.Instance.Hid.InputConfig.Event += Hid.RefreshInputConfigEvent; - - Logger.Info?.Print(LogClass.Application, $"AudioBackend: {ConfigurationState.Instance.System.AudioBackend.Value}"); - Logger.Info?.Print(LogClass.Application, $"IsDocked: {ConfigurationState.Instance.System.EnableDockedMode.Value}"); - Logger.Info?.Print(LogClass.Application, $"Vsync: {ConfigurationState.Instance.Graphics.EnableVsync.Value}"); - Logger.Info?.Print(LogClass.Application, $"MemoryConfiguration: {_memoryConfiguration}"); } public static IntegrityCheckLevel GetIntegrityCheckLevel() diff --git a/Ryujinx/Ui/GLRenderer.cs b/Ryujinx/Ui/GLRenderer.cs index c7c41d6fc..76bf5fa5f 100644 --- a/Ryujinx/Ui/GLRenderer.cs +++ b/Ryujinx/Ui/GLRenderer.cs @@ -8,7 +8,6 @@ using OpenTK.Input; using Ryujinx.Common; using Ryujinx.Common.Configuration; using Ryujinx.Common.Configuration.Hid; -using Ryujinx.Common.Logging; using Ryujinx.Configuration; using Ryujinx.Graphics.OpenGL; using Ryujinx.HLE.HOS.Services.Hid; @@ -670,8 +669,6 @@ namespace Ryujinx.Ui !_prevHotkeyButtons.HasFlag(HotkeyButtons.ToggleVSync)) { _device.EnableDeviceVsync = !_device.EnableDeviceVsync; - - Logger.Info?.Print(LogClass.Application, $"Vsync toggled to: {_device.EnableDeviceVsync}"); } _prevHotkeyButtons = currentHotkeyButtons; diff --git a/Ryujinx/Ui/Windows/SettingsWindow.cs b/Ryujinx/Ui/Windows/SettingsWindow.cs index d4d680909..4cd5eb72e 100644 --- a/Ryujinx/Ui/Windows/SettingsWindow.cs +++ b/Ryujinx/Ui/Windows/SettingsWindow.cs @@ -1,10 +1,8 @@ using Gtk; -using Ryujinx.Audio; using Ryujinx.Audio.Backends.OpenAL; using Ryujinx.Audio.Backends.SoundIo; using Ryujinx.Common.Configuration; using Ryujinx.Common.Configuration.Hid; -using Ryujinx.Common.Logging; using Ryujinx.Configuration; using Ryujinx.Configuration.System; using Ryujinx.HLE.FileSystem; @@ -441,13 +439,7 @@ namespace Ryujinx.Ui.Windows if (_audioBackendSelect.GetActiveIter(out TreeIter activeIter)) { - AudioBackend audioBackend = (AudioBackend)_audioBackendStore.GetValue(activeIter, 1); - if (audioBackend != ConfigurationState.Instance.System.AudioBackend.Value) - { - ConfigurationState.Instance.System.AudioBackend.Value = audioBackend; - - Logger.Info?.Print(LogClass.Application, $"AudioBackend toggled to: {audioBackend}"); - } + ConfigurationState.Instance.System.AudioBackend.Value = (AudioBackend)_audioBackendStore.GetValue(activeIter, 1); } ConfigurationState.Instance.ToFileFormat().SaveConfig(Program.ConfigurationPath);