citra-emu
/
citra
Archived
1
0
Fork 0

logging: Fix log filter during initialization

The log filter was being ignored on initialization due to the logging instance being initialized before the config instance, so the log filter was set to its default value.

This fixes that oversight, along with using descriptive exceptions instead of abort() calls.
This commit is contained in:
ameerj 2023-06-24 03:05:04 +03:00 committed by GPUCode
parent a8340395a3
commit 98e9f4c32e
4 changed files with 16 additions and 11 deletions

View File

@ -171,6 +171,7 @@ static QString PrettyProductName() {
GMainWindow::GMainWindow(Core::System& system_) 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();
Debugger::ToggleConsole(); Debugger::ToggleConsole();
Settings::LogSettings(); Settings::LogSettings();
@ -2853,7 +2854,6 @@ static Qt::HighDpiScaleFactorRoundingPolicy GetHighDpiRoundingPolicy() {
} }
int main(int argc, char* argv[]) { int main(int argc, char* argv[]) {
Common::Log::Initialize();
Common::DetachedTasks detached_tasks; Common::DetachedTasks detached_tasks;
MicroProfileOnThreadCreate("Frontend"); MicroProfileOnThreadCreate("Frontend");
SCOPE_EXIT({ MicroProfileShutdown(); }); SCOPE_EXIT({ MicroProfileShutdown(); });

View File

@ -3,6 +3,7 @@
// Refer to the license.txt file included. // Refer to the license.txt file included.
#include <chrono> #include <chrono>
#include <exception>
#include <thread> #include <thread>
#include <vector> #include <vector>
#include "common/common_paths.h" #include "common/common_paths.h"
@ -177,7 +178,7 @@ public:
}; };
#endif #endif
bool initialization_in_progress_suppress_logging = false; bool initialization_in_progress_suppress_logging = true;
#ifdef CITRA_LINUX_GCC_BACKTRACE #ifdef CITRA_LINUX_GCC_BACKTRACE
[[noreturn]] void SleepForever() { [[noreturn]] void SleepForever() {
@ -194,14 +195,15 @@ class Impl {
public: public:
static Impl& Instance() { static Impl& Instance() {
if (!instance) { if (!instance) {
abort(); throw std::runtime_error("Using Logging instance before its initialization");
} }
return *instance; return *instance;
} }
static void Initialize() { static void Initialize() {
if (instance) { if (instance) {
abort(); LOG_WARNING(Log, "Reinitializing logging backend");
return;
} }
initialization_in_progress_suppress_logging = true; initialization_in_progress_suppress_logging = true;
const auto& log_dir = FileUtil::GetUserPath(FileUtil::UserPath::LogDir); const auto& log_dir = FileUtil::GetUserPath(FileUtil::UserPath::LogDir);

View File

@ -2,6 +2,7 @@
// Licensed under GPLv2 or any later version // Licensed under GPLv2 or any later version
// Refer to the license.txt file included. // Refer to the license.txt file included.
#include <exception>
#include <memory> #include <memory>
#include <stdexcept> #include <stdexcept>
#include <utility> #include <utility>
@ -68,9 +69,16 @@ Core::Timing& Global() {
System::~System() = default; System::~System() = default;
System& System::GetInstance() {
if (!s_instance) {
throw std::runtime_error("Using System instance before its initialization");
}
return *s_instance;
}
void System::InitializeGlobalInstance() { void System::InitializeGlobalInstance() {
if (s_instance) { if (s_instance) {
std::abort(); throw std::runtime_error("Reinitializing Global System instance.");
} }
s_instance = std::unique_ptr<System>(new System); s_instance = std::unique_ptr<System>(new System);
} }

View File

@ -73,12 +73,7 @@ public:
* Gets the instance of the System singleton class. * Gets the instance of the System singleton class.
* @returns Reference to the instance of the System singleton class. * @returns Reference to the instance of the System singleton class.
*/ */
[[nodiscard]] static System& GetInstance() { [[nodiscard]] static System& GetInstance();
if (!s_instance) {
std::abort();
}
return *s_instance;
}
static void InitializeGlobalInstance(); static void InitializeGlobalInstance();