diff --git a/src/citra/citra.cpp b/src/citra/citra.cpp index b8ebb1ff17..7fc8188c8f 100644 --- a/src/citra/citra.cpp +++ b/src/citra/citra.cpp @@ -175,6 +175,8 @@ static void OnStatusMessageReceived(const Network::StatusMessageEntry& msg) { } static void InitializeLogging() { + using namespace Common; + Log::Filter log_filter(Log::Level::Debug); log_filter.ParseFilterString(Settings::values.log_filter.GetValue()); Log::SetGlobalFilter(log_filter); diff --git a/src/citra_qt/configuration/configure_debug.cpp b/src/citra_qt/configuration/configure_debug.cpp index a75592fe0f..5ec1414672 100644 --- a/src/citra_qt/configuration/configure_debug.cpp +++ b/src/citra_qt/configuration/configure_debug.cpp @@ -89,9 +89,9 @@ void ConfigureDebug::ApplyConfiguration() { UISettings::values.show_console = ui->toggle_console->isChecked(); Settings::values.log_filter = ui->log_filter_edit->text().toStdString(); Debugger::ToggleConsole(); - Log::Filter filter; + Common::Log::Filter filter; filter.ParseFilterString(Settings::values.log_filter.GetValue()); - Log::SetGlobalFilter(filter); + Common::Log::SetGlobalFilter(filter); Settings::values.use_cpu_jit = ui->toggle_cpu_jit->isChecked(); Settings::values.renderer_debug = ui->toggle_renderer_debug->isChecked(); diff --git a/src/citra_qt/debugger/console.cpp b/src/citra_qt/debugger/console.cpp index eecf86048d..4fb8d83dbe 100644 --- a/src/citra_qt/debugger/console.cpp +++ b/src/citra_qt/debugger/console.cpp @@ -29,13 +29,13 @@ void ToggleConsole() { freopen_s(&temp, "CONIN$", "r", stdin); freopen_s(&temp, "CONOUT$", "w", stdout); freopen_s(&temp, "CONOUT$", "w", stderr); - Log::AddBackend(std::make_unique()); + Common::Log::AddBackend(std::make_unique()); } } else { if (FreeConsole()) { // In order to close the console, we have to also detach the streams on it. // Just redirect them to NUL if there is no console window - Log::RemoveBackend(Log::ColorConsoleBackend::Name()); + Common::Log::RemoveBackend(Common::Log::ColorConsoleBackend::Name()); freopen_s(&temp, "NUL", "r", stdin); freopen_s(&temp, "NUL", "w", stdout); freopen_s(&temp, "NUL", "w", stderr); diff --git a/src/citra_qt/main.cpp b/src/citra_qt/main.cpp index c00d277fd7..b69bcf3d0e 100644 --- a/src/citra_qt/main.cpp +++ b/src/citra_qt/main.cpp @@ -147,6 +147,8 @@ void GMainWindow::ShowTelemetryCallout() { const int GMainWindow::max_recent_files_item; static void InitializeLogging() { + using namespace Common; + Log::Filter log_filter; log_filter.ParseFilterString(Settings::values.log_filter.GetValue()); Log::SetGlobalFilter(log_filter); diff --git a/src/common/logging/backend.cpp b/src/common/logging/backend.cpp index bb77991fd9..cf955b0930 100644 --- a/src/common/logging/backend.cpp +++ b/src/common/logging/backend.cpp @@ -22,7 +22,7 @@ #include "common/string_util.h" #include "common/threadsafe_queue.h" -namespace Log { +namespace Common::Log { Filter filter; void SetGlobalFilter(const Filter& f) { @@ -302,4 +302,4 @@ void FmtLogMessageImpl(Class log_class, Level log_level, const char* filename, instance.PushEntry(log_class, log_level, filename, line_num, function, fmt::vformat(format, args)); } -} // namespace Log +} // namespace Common::Log diff --git a/src/common/logging/backend.h b/src/common/logging/backend.h index eab6db9bb1..eeb360aa49 100644 --- a/src/common/logging/backend.h +++ b/src/common/logging/backend.h @@ -12,7 +12,7 @@ #include "common/logging/filter.h" #include "common/logging/log.h" -namespace Log { +namespace Common::Log { /** * A log entry. Log entries are store in a structured format to permit more varied output @@ -143,4 +143,4 @@ const char* GetLogClassName(Class log_class); */ const char* GetLevelName(Level log_level); -} // namespace Log +} // namespace Common::Log diff --git a/src/common/logging/filter.cpp b/src/common/logging/filter.cpp index fa42b6047d..942873575f 100644 --- a/src/common/logging/filter.cpp +++ b/src/common/logging/filter.cpp @@ -7,7 +7,7 @@ #include "common/logging/filter.h" #include "common/string_util.h" -namespace Log { +namespace Common::Log { namespace { template Level GetLevelByName(const It begin, const It end) { @@ -96,4 +96,4 @@ bool Filter::CheckMessage(Class log_class, Level level) const { return static_cast(level) >= static_cast(class_levels[static_cast(log_class)]); } -} // namespace Log +} // namespace Common::Log diff --git a/src/common/logging/filter.h b/src/common/logging/filter.h index 058c7b345d..3a8f23e368 100644 --- a/src/common/logging/filter.h +++ b/src/common/logging/filter.h @@ -9,4 +9,4 @@ #include #include "common/logging/log.h" -namespace Log {} // namespace Log +namespace Common::Log {} // namespace Common::Log diff --git a/src/common/logging/log.h b/src/common/logging/log.h index 8cd98db14c..e6a3ea5b22 100644 --- a/src/common/logging/log.h +++ b/src/common/logging/log.h @@ -9,7 +9,7 @@ #include "common/common_types.h" #include "common/logging/formatter.h" -namespace Log { +namespace Common::Log { // trims up to and including the last of ../, ..\, src/, src\ in a string constexpr const char* TrimSourcePath(std::string_view source) { @@ -173,33 +173,39 @@ void FmtLogMessage(Class log_class, Level log_level, const char* filename, unsig fmt::make_format_args(args...)); } -} // namespace Log +} // namespace Common::Log // Define the fmt lib macros #define LOG_GENERIC(log_class, log_level, ...) \ - ::Log::FmtLogMessage(log_class, log_level, ::Log::TrimSourcePath(__FILE__), __LINE__, \ - __func__, __VA_ARGS__) + Common::Log::FmtLogMessage(log_class, log_level, Common::Log::TrimSourcePath(__FILE__), \ + __LINE__, __func__, __VA_ARGS__) #ifdef _DEBUG #define LOG_TRACE(log_class, ...) \ - ::Log::FmtLogMessage(::Log::Class::log_class, ::Log::Level::Trace, \ - ::Log::TrimSourcePath(__FILE__), __LINE__, __func__, __VA_ARGS__) + Common::Log::FmtLogMessage(Common::Log::Class::log_class, Common::Log::Level::Trace, \ + Common::Log::TrimSourcePath(__FILE__), __LINE__, __func__, \ + __VA_ARGS__) #else #define LOG_TRACE(log_class, fmt, ...) (void(0)) #endif #define LOG_DEBUG(log_class, ...) \ - ::Log::FmtLogMessage(::Log::Class::log_class, ::Log::Level::Debug, \ - ::Log::TrimSourcePath(__FILE__), __LINE__, __func__, __VA_ARGS__) + Common::Log::FmtLogMessage(Common::Log::Class::log_class, Common::Log::Level::Debug, \ + Common::Log::TrimSourcePath(__FILE__), __LINE__, __func__, \ + __VA_ARGS__) #define LOG_INFO(log_class, ...) \ - ::Log::FmtLogMessage(::Log::Class::log_class, ::Log::Level::Info, \ - ::Log::TrimSourcePath(__FILE__), __LINE__, __func__, __VA_ARGS__) + Common::Log::FmtLogMessage(Common::Log::Class::log_class, Common::Log::Level::Info, \ + Common::Log::TrimSourcePath(__FILE__), __LINE__, __func__, \ + __VA_ARGS__) #define LOG_WARNING(log_class, ...) \ - ::Log::FmtLogMessage(::Log::Class::log_class, ::Log::Level::Warning, \ - ::Log::TrimSourcePath(__FILE__), __LINE__, __func__, __VA_ARGS__) + Common::Log::FmtLogMessage(Common::Log::Class::log_class, Common::Log::Level::Warning, \ + Common::Log::TrimSourcePath(__FILE__), __LINE__, __func__, \ + __VA_ARGS__) #define LOG_ERROR(log_class, ...) \ - ::Log::FmtLogMessage(::Log::Class::log_class, ::Log::Level::Error, \ - ::Log::TrimSourcePath(__FILE__), __LINE__, __func__, __VA_ARGS__) + Common::Log::FmtLogMessage(Common::Log::Class::log_class, Common::Log::Level::Error, \ + Common::Log::TrimSourcePath(__FILE__), __LINE__, __func__, \ + __VA_ARGS__) #define LOG_CRITICAL(log_class, ...) \ - ::Log::FmtLogMessage(::Log::Class::log_class, ::Log::Level::Critical, \ - ::Log::TrimSourcePath(__FILE__), __LINE__, __func__, __VA_ARGS__) + Common::Log::FmtLogMessage(Common::Log::Class::log_class, Common::Log::Level::Critical, \ + Common::Log::TrimSourcePath(__FILE__), __LINE__, __func__, \ + __VA_ARGS__) diff --git a/src/common/logging/text_formatter.cpp b/src/common/logging/text_formatter.cpp index 7f713b1484..e66bfa43f8 100644 --- a/src/common/logging/text_formatter.cpp +++ b/src/common/logging/text_formatter.cpp @@ -18,7 +18,7 @@ #include "common/logging/text_formatter.h" #include "common/string_util.h" -namespace Log { +namespace Common::Log { std::string FormatLogMessage(const Entry& entry) { unsigned int time_seconds = static_cast(entry.timestamp.count() / 1000000); @@ -141,4 +141,4 @@ void PrintMessageToLogcat([[maybe_unused]] const Entry& entry) { __android_log_print(android_log_priority, "CitraNative", "%s", str.c_str()); #endif } -} // namespace Log +} // namespace Common::Log diff --git a/src/common/logging/text_formatter.h b/src/common/logging/text_formatter.h index 13430951d9..a15b41c42a 100644 --- a/src/common/logging/text_formatter.h +++ b/src/common/logging/text_formatter.h @@ -7,7 +7,7 @@ #include #include -namespace Log { +namespace Common::Log { struct Entry; @@ -19,4 +19,4 @@ void PrintMessage(const Entry& entry); void PrintColoredMessage(const Entry& entry); /// Formats and prints a log entry to the android logcat. void PrintMessageToLogcat(const Entry& entry); -} // namespace Log +} // namespace Common::Log diff --git a/src/core/hle/kernel/process.cpp b/src/core/hle/kernel/process.cpp index f10baa064d..2a5d152093 100644 --- a/src/core/hle/kernel/process.cpp +++ b/src/core/hle/kernel/process.cpp @@ -203,7 +203,7 @@ void Process::Run(s32 main_thread_priority, u32 stack_size) { status = ProcessStatus::Running; - vm_manager.LogLayout(Log::Level::Debug); + vm_manager.LogLayout(Common::Log::Level::Debug); Kernel::SetupMainThread(kernel, codeset->entrypoint, main_thread_priority, SharedFrom(this)); } diff --git a/src/core/hle/kernel/svc.cpp b/src/core/hle/kernel/svc.cpp index 4c075b541e..47b02f495d 100644 --- a/src/core/hle/kernel/svc.cpp +++ b/src/core/hle/kernel/svc.cpp @@ -529,7 +529,7 @@ ResultCode SVC::ControlMemory(u32* out_addr, u32 addr0, u32 addr1, u32 size, u32 return ERR_INVALID_COMBINATION; } - process.vm_manager.LogLayout(Log::Level::Trace); + process.vm_manager.LogLayout(Common::Log::Level::Trace); return RESULT_SUCCESS; } diff --git a/src/core/hle/kernel/vm_manager.cpp b/src/core/hle/kernel/vm_manager.cpp index 49533bb7e9..cb087cbc91 100644 --- a/src/core/hle/kernel/vm_manager.cpp +++ b/src/core/hle/kernel/vm_manager.cpp @@ -239,10 +239,10 @@ ResultCode VMManager::ReprotectRange(VAddr target, u32 size, VMAPermission new_p return RESULT_SUCCESS; } -void VMManager::LogLayout(Log::Level log_level) const { +void VMManager::LogLayout(Common::Log::Level log_level) const { for (const auto& p : vma_map) { const VirtualMemoryArea& vma = p.second; - LOG_GENERIC(::Log::Class::Kernel, log_level, "{:08X} - {:08X} size: {:8X} {}{}{} {}", + LOG_GENERIC(Common::Log::Class::Kernel, log_level, "{:08X} - {:08X} size: {:8X} {}{}{} {}", vma.base, vma.base + vma.size, vma.size, (u8)vma.permissions & (u8)VMAPermission::Read ? 'R' : '-', (u8)vma.permissions & (u8)VMAPermission::Write ? 'W' : '-', diff --git a/src/core/hle/kernel/vm_manager.h b/src/core/hle/kernel/vm_manager.h index 97c601fd6e..87ecbc0375 100644 --- a/src/core/hle/kernel/vm_manager.h +++ b/src/core/hle/kernel/vm_manager.h @@ -202,7 +202,7 @@ public: ResultCode ReprotectRange(VAddr target, u32 size, VMAPermission new_perms); /// Dumps the address space layout to the log, for debugging - void LogLayout(Log::Level log_level) const; + void LogLayout(Common::Log::Level log_level) const; /// Gets a list of backing memory blocks for the specified range ResultVal>> GetBackingBlocksForRange(VAddr address, diff --git a/src/dedicated_room/citra-room.cpp b/src/dedicated_room/citra-room.cpp index 46072de2d0..4e68b34963 100644 --- a/src/dedicated_room/citra-room.cpp +++ b/src/dedicated_room/citra-room.cpp @@ -150,6 +150,8 @@ static void SaveBanList(const Network::Room::BanList& ban_list, const std::strin } static void InitializeLogging(const std::string& log_file) { + using namespace Common; + Log::AddBackend(std::make_unique()); const std::string& log_dir = FileUtil::GetUserPath(FileUtil::UserPath::LogDir); diff --git a/src/video_core/renderer_opengl/gl_driver.cpp b/src/video_core/renderer_opengl/gl_driver.cpp index 9951d0ae74..c0b8c2fe4e 100644 --- a/src/video_core/renderer_opengl/gl_driver.cpp +++ b/src/video_core/renderer_opengl/gl_driver.cpp @@ -56,22 +56,22 @@ inline std::string_view GetType(GLenum type) { static void APIENTRY DebugHandler(GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length, const GLchar* message, const void* user_param) { - Log::Level level = Log::Level::Info; + auto level = Common::Log::Level::Info; switch (severity) { case GL_DEBUG_SEVERITY_HIGH: - level = Log::Level::Critical; + level = Common::Log::Level::Critical; break; case GL_DEBUG_SEVERITY_MEDIUM: - level = Log::Level::Warning; + level = Common::Log::Level::Warning; break; case GL_DEBUG_SEVERITY_NOTIFICATION: case GL_DEBUG_SEVERITY_LOW: - level = Log::Level::Debug; + level = Common::Log::Level::Debug; break; } - LOG_GENERIC(Log::Class::Render_OpenGL, level, "{} {} {}: {}", GetSource(source), GetType(type), - id, message); + LOG_GENERIC(Common::Log::Class::Render_OpenGL, level, "{} {} {}: {}", GetSource(source), + GetType(type), id, message); } Driver::Driver(Core::TelemetrySession& telemetry_session_) diff --git a/src/video_core/renderer_vulkan/vk_platform.cpp b/src/video_core/renderer_vulkan/vk_platform.cpp index dafb86a8dc..46f44e8d47 100644 --- a/src/video_core/renderer_vulkan/vk_platform.cpp +++ b/src/video_core/renderer_vulkan/vk_platform.cpp @@ -38,23 +38,23 @@ static VKAPI_ATTR VkBool32 VKAPI_CALL DebugUtilsCallback( break; } - Log::Level level{}; + Common::Log::Level level{}; switch (severity) { case VK_DEBUG_UTILS_MESSAGE_SEVERITY_ERROR_BIT_EXT: - level = Log::Level::Error; + level = Common::Log::Level::Error; break; case VK_DEBUG_UTILS_MESSAGE_SEVERITY_WARNING_BIT_EXT: - level = Log::Level::Info; + level = Common::Log::Level::Info; break; case VK_DEBUG_UTILS_MESSAGE_SEVERITY_INFO_BIT_EXT: case VK_DEBUG_UTILS_MESSAGE_SEVERITY_VERBOSE_BIT_EXT: - level = Log::Level::Debug; + level = Common::Log::Level::Debug; break; default: - level = Log::Level::Info; + level = Common::Log::Level::Info; } - LOG_GENERIC(Log::Class::Render_Vulkan, level, "{}: {}", + LOG_GENERIC(Common::Log::Class::Render_Vulkan, level, "{}: {}", callback_data->pMessageIdName ? callback_data->pMessageIdName : "", callback_data->pMessage ? callback_data->pMessage : ""); @@ -69,25 +69,25 @@ static VKAPI_ATTR VkBool32 VKAPI_CALL DebugReportCallback(VkDebugReportFlagsEXT const char* pMessage, void* pUserData) { const VkDebugReportFlagBitsEXT severity = static_cast(flags); - Log::Level level{}; + Common::Log::Level level{}; switch (severity) { case VK_DEBUG_REPORT_ERROR_BIT_EXT: - level = Log::Level::Error; + level = Common::Log::Level::Error; break; case VK_DEBUG_REPORT_INFORMATION_BIT_EXT: - level = Log::Level::Warning; + level = Common::Log::Level::Warning; break; case VK_DEBUG_REPORT_DEBUG_BIT_EXT: case VK_DEBUG_REPORT_WARNING_BIT_EXT: case VK_DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT: - level = Log::Level::Debug; + level = Common::Log::Level::Debug; break; default: - level = Log::Level::Info; + level = Common::Log::Level::Info; } const vk::DebugReportObjectTypeEXT type = static_cast(objectType); - LOG_GENERIC(Log::Class::Render_Vulkan, level, + LOG_GENERIC(Common::Log::Class::Render_Vulkan, level, "type = {}, object = {} | MessageCode = {:#x}, LayerPrefix = {} | {}", vk::to_string(type), object, messageCode, pLayerPrefix, pMessage);