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 <unordered_map>
#include <inih/cpp/INIReader.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"
@ -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);

View file

@ -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);

View file

@ -172,8 +172,9 @@ GMainWindow::GMainWindow(Core::System& system_)
: ui{std::make_unique<Ui::MainWindow>()}, system{system_}, movie{Core::Movie::GetInstance()},
config{std::make_unique<Config>()}, 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>("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();

View file

@ -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<Impl, decltype(&Deleter)>(new Impl(log_dir + LOG_FILE, filter),
Deleter);
instance = std::unique_ptr<Impl, decltype(&Deleter)>(
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() {

View file

@ -4,6 +4,7 @@
#pragma once
#include <string_view>
#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();

View file

@ -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;
};

View file

@ -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

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) {
Common::Log::Initialize();
Common::Log::Initialize(log_file);
Common::Log::SetColorConsoleBackendEnabled(true);
}