common: Address feedback

This commit is contained in:
GPUCode 2023-07-03 02:17:03 +03:00
parent 9527bfffed
commit d7b4260389
8 changed files with 29 additions and 16 deletions

View file

@ -7,8 +7,8 @@
#include <sstream> #include <sstream>
#include <unordered_map> #include <unordered_map>
#include <inih/cpp/INIReader.h> #include <inih/cpp/INIReader.h>
#include "common/file_util.h" #include "common/file_util.h"
#include "common/logging/backend.h"
#include "common/logging/log.h" #include "common/logging/log.h"
#include "common/param_package.h" #include "common/param_package.h"
#include "common/settings.h" #include "common/settings.h"
@ -260,6 +260,12 @@ void Config::ReadValues() {
// Miscellaneous // Miscellaneous
ReadSetting("Miscellaneous", Settings::values.log_filter); 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 // Debugging
Settings::values.record_frame_times = Settings::values.record_frame_times =
sdl2_config->GetBoolean("Debugging", "record_frame_times", false); sdl2_config->GetBoolean("Debugging", "record_frame_times", false);

View file

@ -11,8 +11,8 @@
#include "citra/config.h" #include "citra/config.h"
#include "citra/default_ini.h" #include "citra/default_ini.h"
#include "common/file_util.h" #include "common/file_util.h"
#include "common/logging/backend.h"
#include "common/logging/log.h" #include "common/logging/log.h"
#include "common/param_package.h"
#include "common/settings.h" #include "common/settings.h"
#include "core/hle/service/service.h" #include "core/hle/service/service.h"
#include "input_common/main.h" #include "input_common/main.h"
@ -299,6 +299,12 @@ void Config::ReadValues() {
// Miscellaneous // Miscellaneous
ReadSetting("Miscellaneous", Settings::values.log_filter); 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 // Debugging
Settings::values.record_frame_times = Settings::values.record_frame_times =
sdl2_config->GetBoolean("Debugging", "record_frame_times", false); sdl2_config->GetBoolean("Debugging", "record_frame_times", false);

View file

@ -172,8 +172,9 @@ GMainWindow::GMainWindow(Core::System& system_)
: ui{std::make_unique<Ui::MainWindow>()}, system{system_}, movie{Core::Movie::GetInstance()}, : ui{std::make_unique<Ui::MainWindow>()}, system{system_}, movie{Core::Movie::GetInstance()},
config{std::make_unique<Config>()}, emu_thread{nullptr} { config{std::make_unique<Config>()}, emu_thread{nullptr} {
Common::Log::Initialize(); Common::Log::Initialize();
Common::Log::Start();
Debugger::ToggleConsole(); Debugger::ToggleConsole();
Settings::LogSettings();
// register types to use in slots and signals // register types to use in slots and signals
qRegisterMetaType<std::size_t>("std::size_t"); qRegisterMetaType<std::size_t>("std::size_t");
@ -264,8 +265,6 @@ GMainWindow::GMainWindow(Core::System& system_)
} }
#endif #endif
Common::Log::Start();
QStringList args = QApplication::arguments(); QStringList args = QApplication::arguments();
if (args.length() >= 2) { if (args.length() >= 2) {
BootGame(args[1]); BootGame(args[1]);
@ -1143,9 +1142,10 @@ void GMainWindow::BootGame(const QString& filename) {
system.ApplySettings(); system.ApplySettings();
LOG_INFO(Frontend, "Using per game config file for title id {}", config_file_name); LOG_INFO(Frontend, "Using per game config file for title id {}", config_file_name);
Settings::LogSettings();
} }
Settings::LogSettings();
// Save configurations // Save configurations
UpdateUISettings(); UpdateUISettings();
game_list->SaveInterfaceLayout(); game_list->SaveInterfaceLayout();

View file

@ -202,7 +202,7 @@ public:
return *instance; return *instance;
} }
static void Initialize() { static void Initialize(std::string_view log_file) {
if (instance) { if (instance) {
LOG_WARNING(Log, "Reinitializing logging backend"); LOG_WARNING(Log, "Reinitializing logging backend");
return; return;
@ -212,8 +212,8 @@ public:
void(FileUtil::CreateDir(log_dir)); void(FileUtil::CreateDir(log_dir));
Filter filter; Filter filter;
filter.ParseFilterString(Settings::values.log_filter.GetValue()); filter.ParseFilterString(Settings::values.log_filter.GetValue());
instance = std::unique_ptr<Impl, decltype(&Deleter)>(new Impl(log_dir + LOG_FILE, filter), instance = std::unique_ptr<Impl, decltype(&Deleter)>(
Deleter); new Impl(fmt::format("{}{}", log_dir, log_file), filter), Deleter);
initialization_in_progress_suppress_logging = false; initialization_in_progress_suppress_logging = false;
} }
@ -414,8 +414,8 @@ private:
}; };
} // namespace } // namespace
void Initialize() { void Initialize(std::string_view log_file) {
Impl::Initialize(); Impl::Initialize(log_file.empty() ? LOG_FILE : log_file);
} }
void Start() { void Start() {

View file

@ -4,6 +4,7 @@
#pragma once #pragma once
#include <string_view>
#include "common/logging/filter.h" #include "common/logging/filter.h"
namespace Common::Log { namespace Common::Log {
@ -11,7 +12,7 @@ namespace Common::Log {
class Filter; class Filter;
/// Initializes the logging system. This should be the first thing called in main. /// Initializes the logging system. This should be the first thing called in main.
void Initialize(); void Initialize(std::string_view log_file = "");
void Start(); void Start();

View file

@ -19,7 +19,7 @@ struct Entry {
Class log_class{}; Class log_class{};
Level log_level{}; Level log_level{};
const char* filename = nullptr; const char* filename = nullptr;
unsigned int line_num = 0; u32 line_num = 0;
std::string function; std::string function;
std::string message; std::string message;
}; };

View file

@ -20,7 +20,7 @@ enum class Level : u8 {
Critical, ///< Major problems during execution that threaten the stability of the entire Critical, ///< Major problems during execution that threaten the stability of the entire
///< application. ///< 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 Movie, ///< Movie (Input Recording) Playback
WebService, ///< Interface to Citra Web Services WebService, ///< Interface to Citra Web Services
RPC_Server, ///< RPC server RPC_Server, ///< RPC server
Count ///< Total number of logging classes Count, ///< Total number of logging classes
}; };
} // namespace Common::Log } // namespace Common::Log

View file

@ -150,7 +150,7 @@ static void SaveBanList(const Network::Room::BanList& ban_list, const std::strin
} }
static void InitializeLogging(const std::string& log_file) { static void InitializeLogging(const std::string& log_file) {
Common::Log::Initialize(); Common::Log::Initialize(log_file);
Common::Log::SetColorConsoleBackendEnabled(true); Common::Log::SetColorConsoleBackendEnabled(true);
} }