From d7b42603896ac152b4080c2482f908c2beb75e0a Mon Sep 17 00:00:00 2001 From: GPUCode Date: Mon, 3 Jul 2023 02:17:03 +0300 Subject: [PATCH] common: Address feedback --- src/android/app/src/main/jni/config.cpp | 8 +++++++- src/citra/config.cpp | 8 +++++++- src/citra_qt/main.cpp | 8 ++++---- src/common/logging/backend.cpp | 10 +++++----- src/common/logging/backend.h | 3 ++- src/common/logging/log_entry.h | 2 +- src/common/logging/types.h | 4 ++-- src/dedicated_room/citra-room.cpp | 2 +- 8 files changed, 29 insertions(+), 16 deletions(-) diff --git a/src/android/app/src/main/jni/config.cpp b/src/android/app/src/main/jni/config.cpp index 8c3273279a..7efdeefcde 100644 --- a/src/android/app/src/main/jni/config.cpp +++ b/src/android/app/src/main/jni/config.cpp @@ -7,8 +7,8 @@ #include #include #include - #include "common/file_util.h" +#include "common/logging/backend.h" #include "common/logging/log.h" #include "common/param_package.h" #include "common/settings.h" @@ -260,6 +260,12 @@ void Config::ReadValues() { // Miscellaneous ReadSetting("Miscellaneous", Settings::values.log_filter); + // Apply the log_filter setting as the logger has already been initialized + // and doesn't pick up the filter on its own. + Common::Log::Filter filter; + filter.ParseFilterString(Settings::values.log_filter.GetValue()); + Common::Log::SetGlobalFilter(filter); + // Debugging Settings::values.record_frame_times = sdl2_config->GetBoolean("Debugging", "record_frame_times", false); diff --git a/src/citra/config.cpp b/src/citra/config.cpp index 09fda6ca5a..5edaf42da5 100644 --- a/src/citra/config.cpp +++ b/src/citra/config.cpp @@ -11,8 +11,8 @@ #include "citra/config.h" #include "citra/default_ini.h" #include "common/file_util.h" +#include "common/logging/backend.h" #include "common/logging/log.h" -#include "common/param_package.h" #include "common/settings.h" #include "core/hle/service/service.h" #include "input_common/main.h" @@ -299,6 +299,12 @@ void Config::ReadValues() { // Miscellaneous ReadSetting("Miscellaneous", Settings::values.log_filter); + // Apply the log_filter setting as the logger has already been initialized + // and doesn't pick up the filter on its own. + Common::Log::Filter filter; + filter.ParseFilterString(Settings::values.log_filter.GetValue()); + Common::Log::SetGlobalFilter(filter); + // Debugging Settings::values.record_frame_times = sdl2_config->GetBoolean("Debugging", "record_frame_times", false); diff --git a/src/citra_qt/main.cpp b/src/citra_qt/main.cpp index 46b8fdfb2f..359abeea02 100644 --- a/src/citra_qt/main.cpp +++ b/src/citra_qt/main.cpp @@ -172,8 +172,9 @@ GMainWindow::GMainWindow(Core::System& system_) : ui{std::make_unique()}, system{system_}, movie{Core::Movie::GetInstance()}, config{std::make_unique()}, emu_thread{nullptr} { Common::Log::Initialize(); + Common::Log::Start(); + Debugger::ToggleConsole(); - Settings::LogSettings(); // register types to use in slots and signals qRegisterMetaType("std::size_t"); @@ -264,8 +265,6 @@ GMainWindow::GMainWindow(Core::System& system_) } #endif - Common::Log::Start(); - QStringList args = QApplication::arguments(); if (args.length() >= 2) { BootGame(args[1]); @@ -1143,9 +1142,10 @@ void GMainWindow::BootGame(const QString& filename) { system.ApplySettings(); LOG_INFO(Frontend, "Using per game config file for title id {}", config_file_name); - Settings::LogSettings(); } + Settings::LogSettings(); + // Save configurations UpdateUISettings(); game_list->SaveInterfaceLayout(); diff --git a/src/common/logging/backend.cpp b/src/common/logging/backend.cpp index d868b26094..5c80cdff0f 100644 --- a/src/common/logging/backend.cpp +++ b/src/common/logging/backend.cpp @@ -202,7 +202,7 @@ public: return *instance; } - static void Initialize() { + static void Initialize(std::string_view log_file) { if (instance) { LOG_WARNING(Log, "Reinitializing logging backend"); return; @@ -212,8 +212,8 @@ public: void(FileUtil::CreateDir(log_dir)); Filter filter; filter.ParseFilterString(Settings::values.log_filter.GetValue()); - instance = std::unique_ptr(new Impl(log_dir + LOG_FILE, filter), - Deleter); + instance = std::unique_ptr( + new Impl(fmt::format("{}{}", log_dir, log_file), filter), Deleter); initialization_in_progress_suppress_logging = false; } @@ -414,8 +414,8 @@ private: }; } // namespace -void Initialize() { - Impl::Initialize(); +void Initialize(std::string_view log_file) { + Impl::Initialize(log_file.empty() ? LOG_FILE : log_file); } void Start() { diff --git a/src/common/logging/backend.h b/src/common/logging/backend.h index a0e80fe3c1..19a5ef0f46 100644 --- a/src/common/logging/backend.h +++ b/src/common/logging/backend.h @@ -4,6 +4,7 @@ #pragma once +#include #include "common/logging/filter.h" namespace Common::Log { @@ -11,7 +12,7 @@ namespace Common::Log { class Filter; /// Initializes the logging system. This should be the first thing called in main. -void Initialize(); +void Initialize(std::string_view log_file = ""); void Start(); diff --git a/src/common/logging/log_entry.h b/src/common/logging/log_entry.h index b28570071c..290ec784a5 100644 --- a/src/common/logging/log_entry.h +++ b/src/common/logging/log_entry.h @@ -19,7 +19,7 @@ struct Entry { Class log_class{}; Level log_level{}; const char* filename = nullptr; - unsigned int line_num = 0; + u32 line_num = 0; std::string function; std::string message; }; diff --git a/src/common/logging/types.h b/src/common/logging/types.h index e8fc3feade..f4db2dc424 100644 --- a/src/common/logging/types.h +++ b/src/common/logging/types.h @@ -20,7 +20,7 @@ enum class Level : u8 { Critical, ///< Major problems during execution that threaten the stability of the entire ///< application. - Count ///< Total number of logging levels + Count, ///< Total number of logging levels }; /** @@ -100,7 +100,7 @@ enum class Class : u8 { Movie, ///< Movie (Input Recording) Playback WebService, ///< Interface to Citra Web Services RPC_Server, ///< RPC server - Count ///< Total number of logging classes + Count, ///< Total number of logging classes }; } // namespace Common::Log diff --git a/src/dedicated_room/citra-room.cpp b/src/dedicated_room/citra-room.cpp index 78fef0e906..dab153dd99 100644 --- a/src/dedicated_room/citra-room.cpp +++ b/src/dedicated_room/citra-room.cpp @@ -150,7 +150,7 @@ static void SaveBanList(const Network::Room::BanList& ban_list, const std::strin } static void InitializeLogging(const std::string& log_file) { - Common::Log::Initialize(); + Common::Log::Initialize(log_file); Common::Log::SetColorConsoleBackendEnabled(true); }