From fc3a134e7d6148f388b31ac7237921290511d20f Mon Sep 17 00:00:00 2001 From: Megamouse Date: Sat, 28 Mar 2020 15:28:23 +0100 Subject: [PATCH] Emu: make "Silence All Logs" dynamic --- Utilities/Config.cpp | 7 +----- rpcs3/Emu/System.cpp | 36 ++++++++++++++++++++++++++----- rpcs3/Emu/System.h | 9 ++++---- rpcs3/Emu/system_config.h | 2 +- rpcs3/rpcs3qt/gui_application.cpp | 1 + rpcs3/util/logs.cpp | 8 +++++++ rpcs3/util/logs.hpp | 4 ++++ 7 files changed, 51 insertions(+), 16 deletions(-) diff --git a/Utilities/Config.cpp b/Utilities/Config.cpp index 28732b817e..34137efa2b 100644 --- a/Utilities/Config.cpp +++ b/Utilities/Config.cpp @@ -344,12 +344,7 @@ void cfg::set_entry::from_default() void cfg::log_entry::set_map(std::map&& map) { - logs::reset(); - - for (auto&& pair : (m_map = std::move(map))) - { - logs::set_level(pair.first, pair.second); - } + m_map = std::move(map); } void cfg::log_entry::from_default() diff --git a/rpcs3/Emu/System.cpp b/rpcs3/Emu/System.cpp index 8a47b90241..a71ffb5ef0 100644 --- a/rpcs3/Emu/System.cpp +++ b/rpcs3/Emu/System.cpp @@ -31,6 +31,7 @@ #include "../Crypto/unself.h" #include "../Crypto/unpkg.h" #include "util/yaml.hpp" +#include "util/logs.hpp" #include "cereal/archives/binary.hpp" @@ -1528,11 +1529,7 @@ void Emulator::Run(bool start_playtime) m_pause_amend_time = 0; m_state = system_state::running; - if (g_cfg.misc.silence_all_logs) - { - sys_log.notice("Now disabling logging..."); - logs::silence(); - } + ConfigureLogs(); auto on_select = [](u32, cpu_thread& cpu) { @@ -1822,6 +1819,35 @@ s32 error_code::error_report(const fmt_type_info* sup, u64 arg, const fmt_type_i return static_cast(arg); } +void Emulator::ConfigureLogs() +{ + static bool was_silenced = false; + + const bool silenced = g_cfg.misc.silence_all_logs.get(); + + if (silenced) + { + if (!was_silenced) + { + sys_log.notice("Disabling logging..."); + } + + logs::silence(); + } + else + { + logs::reset(); + logs::set_channel_levels(g_cfg.log.get_map()); + + if (was_silenced) + { + sys_log.notice("Logging enabled"); + } + } + + was_silenced = silenced; +} + template <> void stx::manual_fixed_typemap::init_reporter(const char* name, unsigned long long created) const noexcept { diff --git a/rpcs3/Emu/System.h b/rpcs3/Emu/System.h index b870f077d0..c31352b0e3 100644 --- a/rpcs3/Emu/System.h +++ b/rpcs3/Emu/System.h @@ -175,10 +175,6 @@ public: bool BootRsxCapture(const std::string& path); bool InstallPkg(const std::string& path); -private: - void LimitCacheSize(); - -public: #ifdef _WIN32 static std::string GetExeDir(); #endif @@ -214,6 +210,11 @@ public: std::string GetFormattedTitle(double fps) const; u32 GetMaxThreads() const; + + void ConfigureLogs(); + +private: + void LimitCacheSize(); }; extern Emulator Emu; diff --git a/rpcs3/Emu/system_config.h b/rpcs3/Emu/system_config.h index faa7027749..a7265a1637 100644 --- a/rpcs3/Emu/system_config.h +++ b/rpcs3/Emu/system_config.h @@ -264,7 +264,7 @@ struct cfg_root : cfg::node cfg::_bool show_shader_compilation_hint{ this, "Show shader compilation hint", true, true }; cfg::_bool use_native_interface{ this, "Use native user interface", true }; cfg::string gdb_server{ this, "GDB Server", "127.0.0.1:2345" }; - cfg::_bool silence_all_logs{ this, "Silence All Logs", false, false }; + cfg::_bool silence_all_logs{ this, "Silence All Logs", false, true }; cfg::string title_format{ this, "Window Title Format", "FPS: %F | %R | %V | %T [%t]", true }; } misc{ this }; diff --git a/rpcs3/rpcs3qt/gui_application.cpp b/rpcs3/rpcs3qt/gui_application.cpp index 95f56b7184..a50794e149 100644 --- a/rpcs3/rpcs3qt/gui_application.cpp +++ b/rpcs3/rpcs3qt/gui_application.cpp @@ -427,6 +427,7 @@ void gui_application::OnChangeStyleSheetRequest(const QString& path) void gui_application::OnEmuSettingsChange() { + Emu.ConfigureLogs(); rsx::overlays::reset_performance_overlay(); } diff --git a/rpcs3/util/logs.cpp b/rpcs3/util/logs.cpp index 8cc7bc1550..2c87866054 100644 --- a/rpcs3/util/logs.cpp +++ b/rpcs3/util/logs.cpp @@ -208,6 +208,14 @@ namespace logs } } + void set_channel_levels(const std::map& map) + { + for (auto&& pair : map) + { + logs::set_level(pair.first, pair.second); + } + } + std::vector get_channels() { std::vector result; diff --git a/rpcs3/util/logs.hpp b/rpcs3/util/logs.hpp index 51dd1a571a..0cc8828612 100644 --- a/rpcs3/util/logs.hpp +++ b/rpcs3/util/logs.hpp @@ -2,6 +2,7 @@ #include #include +#include #include #include #include @@ -132,6 +133,9 @@ namespace logs // Log level control: get channel level level get_level(const std::string&); + // Log level control: set specific channels to level::fatal + void set_channel_levels(const std::map& map); + // Get all registered log channels std::vector get_channels();