From 616d87444313db865c60fbeee36ebe5250ef301e Mon Sep 17 00:00:00 2001 From: Yuri Kunde Schlesner Date: Tue, 28 Oct 2014 05:36:00 -0200 Subject: New logging system --- src/citra/citra.cpp | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) (limited to 'src/citra') diff --git a/src/citra/citra.cpp b/src/citra/citra.cpp index f2aeb510e..7c031ce8d 100644 --- a/src/citra/citra.cpp +++ b/src/citra/citra.cpp @@ -2,8 +2,12 @@ // Licensed under GPLv2 // Refer to the license.txt file included. +#include + #include "common/common.h" -#include "common/log_manager.h" +#include "common/logging/text_formatter.h" +#include "common/logging/backend.h" +#include "common/scope_exit.h" #include "core/settings.h" #include "core/system.h" @@ -15,7 +19,12 @@ /// Application entry point int __cdecl main(int argc, char **argv) { - LogManager::Init(); + std::shared_ptr logger = Log::InitGlobalLogger(); + std::thread logging_thread(Log::TextLoggingLoop, logger); + SCOPE_EXIT({ + logger->Close(); + logging_thread.join(); + }); if (argc < 2) { ERROR_LOG(BOOT, "Failed to load ROM: No ROM specified"); @@ -24,9 +33,6 @@ int __cdecl main(int argc, char **argv) { Config config; - if (!Settings::values.enable_log) - LogManager::Shutdown(); - std::string boot_filename = argv[1]; EmuWindow_GLFW* emu_window = new EmuWindow_GLFW; -- cgit v1.2.3 From 0600e2d8b5b30bd68c8b19cb1f2051e096e7caa9 Mon Sep 17 00:00:00 2001 From: Yuri Kunde Schlesner Date: Fri, 5 Dec 2014 23:53:49 -0200 Subject: Convert old logging calls to new logging macros --- src/citra/citra.cpp | 4 ++-- src/citra/config.cpp | 6 +++--- src/citra/emu_window/emu_window_glfw.cpp | 16 ++++++++-------- 3 files changed, 13 insertions(+), 13 deletions(-) (limited to 'src/citra') diff --git a/src/citra/citra.cpp b/src/citra/citra.cpp index 7c031ce8d..d192428e9 100644 --- a/src/citra/citra.cpp +++ b/src/citra/citra.cpp @@ -27,7 +27,7 @@ int __cdecl main(int argc, char **argv) { }); if (argc < 2) { - ERROR_LOG(BOOT, "Failed to load ROM: No ROM specified"); + LOG_CRITICAL(Frontend, "Failed to load ROM: No ROM specified"); return -1; } @@ -40,7 +40,7 @@ int __cdecl main(int argc, char **argv) { Loader::ResultStatus load_result = Loader::LoadFile(boot_filename); if (Loader::ResultStatus::Success != load_result) { - ERROR_LOG(BOOT, "Failed to load ROM (Error %i)!", load_result); + LOG_CRITICAL(Frontend, "Failed to load ROM (Error %i)!", load_result); return -1; } diff --git a/src/citra/config.cpp b/src/citra/config.cpp index 1f8f5922b..fe0ebe5a8 100644 --- a/src/citra/config.cpp +++ b/src/citra/config.cpp @@ -22,17 +22,17 @@ Config::Config() { bool Config::LoadINI(INIReader* config, const char* location, const std::string& default_contents, bool retry) { if (config->ParseError() < 0) { if (retry) { - ERROR_LOG(CONFIG, "Failed to load %s. Creating file from defaults...", location); + LOG_WARNING(Config, "Failed to load %s. Creating file from defaults...", location); FileUtil::CreateFullPath(location); FileUtil::WriteStringToFile(true, default_contents, location); *config = INIReader(location); // Reopen file return LoadINI(config, location, default_contents, false); } - ERROR_LOG(CONFIG, "Failed."); + LOG_ERROR(Config, "Failed."); return false; } - INFO_LOG(CONFIG, "Successfully loaded %s", location); + LOG_INFO(Config, "Successfully loaded %s", location); return true; } diff --git a/src/citra/emu_window/emu_window_glfw.cpp b/src/citra/emu_window/emu_window_glfw.cpp index 982619126..929e09f43 100644 --- a/src/citra/emu_window/emu_window_glfw.cpp +++ b/src/citra/emu_window/emu_window_glfw.cpp @@ -36,15 +36,15 @@ const bool EmuWindow_GLFW::IsOpen() { } void EmuWindow_GLFW::OnFramebufferResizeEvent(GLFWwindow* win, int width, int height) { - _dbg_assert_(GUI, width > 0); - _dbg_assert_(GUI, height > 0); + _dbg_assert_(Frontend, width > 0); + _dbg_assert_(Frontend, height > 0); GetEmuWindow(win)->NotifyFramebufferSizeChanged(std::pair(width, height)); } void EmuWindow_GLFW::OnClientAreaResizeEvent(GLFWwindow* win, int width, int height) { - _dbg_assert_(GUI, width > 0); - _dbg_assert_(GUI, height > 0); + _dbg_assert_(Frontend, width > 0); + _dbg_assert_(Frontend, height > 0); // NOTE: GLFW provides no proper way to set a minimal window size. // Hence, we just ignore the corresponding EmuWindow hint. @@ -59,12 +59,12 @@ EmuWindow_GLFW::EmuWindow_GLFW() { ReloadSetKeymaps(); glfwSetErrorCallback([](int error, const char *desc){ - ERROR_LOG(GUI, "GLFW 0x%08x: %s", error, desc); + LOG_ERROR(Frontend, "GLFW 0x%08x: %s", error, desc); }); // Initialize the window if(glfwInit() != GL_TRUE) { - ERROR_LOG(GUI, "Failed to initialize GLFW! Exiting..."); + LOG_CRITICAL(Frontend, "Failed to initialize GLFW! Exiting..."); exit(1); } glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3); @@ -79,7 +79,7 @@ EmuWindow_GLFW::EmuWindow_GLFW() { window_title.c_str(), nullptr, nullptr); if (m_render_window == nullptr) { - ERROR_LOG(GUI, "Failed to create GLFW window! Exiting..."); + LOG_CRITICAL(Frontend, "Failed to create GLFW window! Exiting..."); exit(1); } @@ -149,7 +149,7 @@ void EmuWindow_GLFW::OnMinimalClientAreaChangeRequest(const std::pair current_size; glfwGetWindowSize(m_render_window, ¤t_size.first, ¤t_size.second); - _dbg_assert_(GUI, (int)minimal_size.first > 0 && (int)minimal_size.second > 0); + _dbg_assert_(Frontend, (int)minimal_size.first > 0 && (int)minimal_size.second > 0); int new_width = std::max(current_size.first, (int)minimal_size.first); int new_height = std::max(current_size.second, (int)minimal_size.second); -- cgit v1.2.3 From 0e0a007a2503d468391004c8ea2faae305232345 Mon Sep 17 00:00:00 2001 From: Yuri Kunde Schlesner Date: Sat, 6 Dec 2014 20:00:08 -0200 Subject: Add configurable per-class log filtering --- src/citra/citra.cpp | 5 ++++- src/citra/config.cpp | 2 +- src/citra/default_ini.h | 2 +- 3 files changed, 6 insertions(+), 3 deletions(-) (limited to 'src/citra') diff --git a/src/citra/citra.cpp b/src/citra/citra.cpp index d192428e9..d6e8a4ec7 100644 --- a/src/citra/citra.cpp +++ b/src/citra/citra.cpp @@ -7,6 +7,7 @@ #include "common/common.h" #include "common/logging/text_formatter.h" #include "common/logging/backend.h" +#include "common/logging/filter.h" #include "common/scope_exit.h" #include "core/settings.h" @@ -20,7 +21,8 @@ /// Application entry point int __cdecl main(int argc, char **argv) { std::shared_ptr logger = Log::InitGlobalLogger(); - std::thread logging_thread(Log::TextLoggingLoop, logger); + Log::Filter log_filter(Log::Level::Debug); + std::thread logging_thread(Log::TextLoggingLoop, logger, &log_filter); SCOPE_EXIT({ logger->Close(); logging_thread.join(); @@ -32,6 +34,7 @@ int __cdecl main(int argc, char **argv) { } Config config; + log_filter.ParseFilterString(Settings::values.log_filter); std::string boot_filename = argv[1]; EmuWindow_GLFW* emu_window = new EmuWindow_GLFW; diff --git a/src/citra/config.cpp b/src/citra/config.cpp index fe0ebe5a8..92764809e 100644 --- a/src/citra/config.cpp +++ b/src/citra/config.cpp @@ -64,7 +64,7 @@ void Config::ReadValues() { Settings::values.use_virtual_sd = glfw_config->GetBoolean("Data Storage", "use_virtual_sd", true); // Miscellaneous - Settings::values.enable_log = glfw_config->GetBoolean("Miscellaneous", "enable_log", true); + Settings::values.log_filter = glfw_config->Get("Miscellaneous", "log_filter", "*:Info"); } void Config::Reload() { diff --git a/src/citra/default_ini.h b/src/citra/default_ini.h index f1f626eed..7cf543e07 100644 --- a/src/citra/default_ini.h +++ b/src/citra/default_ini.h @@ -34,7 +34,7 @@ gpu_refresh_rate = ## 60 (default) use_virtual_sd = [Miscellaneous] -enable_log = +log_filter = *:Info ## Examples: *:Debug Kernel.SVC:Trace Service.*:Critical )"; } -- cgit v1.2.3