diff --git a/src/common/logging/backend.cpp b/src/common/logging/backend.cpp index 4a85c4cde..d7c816da3 100644 --- a/src/common/logging/backend.cpp +++ b/src/common/logging/backend.cpp @@ -1,4 +1,5 @@ // SPDX-FileCopyrightText: Copyright 2014 Citra Emulator Project +// SPDX-FileCopyrightText: Copyright 2026 shadPS4 Emulator Project // SPDX-License-Identifier: GPL-2.0-or-later #include @@ -97,6 +98,7 @@ private: std::size_t bytes_written = 0; }; +#ifdef _WIN32 /** * Backend that writes to Visual Studio's output window */ @@ -107,15 +109,14 @@ public: ~DebuggerBackend() = default; void Write(const Entry& entry) { -#ifdef _WIN32 ::OutputDebugStringW(UTF8ToUTF16W(FormatLogMessage(entry).append(1, '\n')).c_str()); -#endif } void Flush() {} void EnableForStacktrace() {} }; +#endif bool initialization_in_progress_suppress_logging = true; @@ -219,6 +220,7 @@ public: .line_num = line_num, .function = function, .message = std::move(message), + .thread = Common::GetCurrentThreadName(), }; if (Config::getLogType() == "async") { message_queue.EmplaceWait(entry); @@ -266,7 +268,9 @@ private: } void ForEachBackend(auto lambda) { - // lambda(debugger_backend); +#ifdef _WIN32 + lambda(debugger_backend); +#endif lambda(color_console_backend); lambda(file_backend); } @@ -279,7 +283,9 @@ private: static inline bool should_append{false}; Filter filter; +#ifdef _WIN32 DebuggerBackend debugger_backend{}; +#endif ColorConsoleBackend color_console_backend{}; FileBackend file_backend; diff --git a/src/common/logging/log_entry.h b/src/common/logging/log_entry.h index cd4ae9355..6c529f878 100644 --- a/src/common/logging/log_entry.h +++ b/src/common/logging/log_entry.h @@ -21,6 +21,7 @@ struct Entry { u32 line_num = 0; std::string function; std::string message; + std::string thread; }; } // namespace Common::Log diff --git a/src/common/logging/text_formatter.cpp b/src/common/logging/text_formatter.cpp index e7a786396..e8c5f4979 100644 --- a/src/common/logging/text_formatter.cpp +++ b/src/common/logging/text_formatter.cpp @@ -14,7 +14,6 @@ #include "common/logging/log.h" #include "common/logging/log_entry.h" #include "common/logging/text_formatter.h" -#include "common/thread.h" namespace Common::Log { @@ -25,9 +24,8 @@ std::string FormatLogMessage(const Entry& entry) { const char* class_name = GetLogClassName(entry.log_class); const char* level_name = GetLevelName(entry.log_level); - return fmt::format("[{}] <{}> ({}) {}:{} {}: {}", class_name, level_name, - Common::GetCurrentThreadName(), entry.filename, entry.line_num, - entry.function, entry.message); + return fmt::format("[{}] <{}> ({}) {}:{} {}: {}", class_name, level_name, entry.thread, + entry.filename, entry.line_num, entry.function, entry.message); } void PrintMessage(const Entry& entry) {