From 0a15d2fcecaa0a0ae32891245bb31eee0a1f0ccd Mon Sep 17 00:00:00 2001 From: Shawn Hoffman Date: Sun, 17 Jul 2022 19:12:04 -0700 Subject: [PATCH 1/2] cubeb: fix logged source file paths --- Source/Core/AudioCommon/CubebUtils.cpp | 10 ++++++++-- Source/Core/Common/Logging/LogManager.h | 5 ++--- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/Source/Core/AudioCommon/CubebUtils.cpp b/Source/Core/AudioCommon/CubebUtils.cpp index 7b998b1db9..ffe1e8cfbb 100644 --- a/Source/Core/AudioCommon/CubebUtils.cpp +++ b/Source/Core/AudioCommon/CubebUtils.cpp @@ -22,6 +22,10 @@ static void LogCallback(const char* format, ...) if (instance == nullptr) return; + constexpr auto log_type = Common::Log::LogType::AUDIO; + if (!instance->IsEnabled(log_type)) + return; + va_list args; va_start(args, format); const char* filename = va_arg(args, const char*) + s_path_cutoff_point; @@ -30,8 +34,8 @@ static void LogCallback(const char* format, ...) const std::string message = StringFromFormatV(adapted_format.c_str(), args); va_end(args); - instance->Log(Common::Log::LogLevel::LNOTICE, Common::Log::LogType::AUDIO, filename, lineno, - message.c_str()); + instance->LogWithFullPath(Common::Log::LogLevel::LNOTICE, log_type, filename, lineno, + message.c_str()); } static void DestroyContext(cubeb* ctx) @@ -54,6 +58,8 @@ std::shared_ptr CubebUtils::GetContext() const char* filename = __FILE__; const char* match_point = strstr(filename, DIR_SEP "Source" DIR_SEP "Core" DIR_SEP); + if (!match_point) + match_point = strstr(filename, R"(\Source\Core\)"); if (match_point) { s_path_cutoff_point = match_point - filename + strlen(DIR_SEP "Externals" DIR_SEP); diff --git a/Source/Core/Common/Logging/LogManager.h b/Source/Core/Common/Logging/LogManager.h index be80835552..acda7f7fe1 100644 --- a/Source/Core/Common/Logging/LogManager.h +++ b/Source/Core/Common/Logging/LogManager.h @@ -39,6 +39,8 @@ public: static void Shutdown(); void Log(LogLevel level, LogType type, const char* file, int line, const char* message); + void LogWithFullPath(LogLevel level, LogType type, const char* file, int line, + const char* message); LogLevel GetLogLevel() const; void SetLogLevel(LogLevel level); @@ -73,9 +75,6 @@ private: LogManager(LogManager&&) = delete; LogManager& operator=(LogManager&&) = delete; - void LogWithFullPath(LogLevel level, LogType type, const char* file, int line, - const char* message); - LogLevel m_level; EnumMap m_log{}; std::array m_listeners{}; From 28828435bbe56d959e0dc14938df6a32169fad91 Mon Sep 17 00:00:00 2001 From: Shawn Hoffman Date: Sun, 17 Jul 2022 19:41:54 -0700 Subject: [PATCH 2/2] Qt/LogWidget: remove extra space --- Source/Core/DolphinQt/Config/LogWidget.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/Core/DolphinQt/Config/LogWidget.cpp b/Source/Core/DolphinQt/Config/LogWidget.cpp index bcb0db6d2c..4e92b2725e 100644 --- a/Source/Core/DolphinQt/Config/LogWidget.cpp +++ b/Source/Core/DolphinQt/Config/LogWidget.cpp @@ -102,7 +102,7 @@ void LogWidget::UpdateLog() const std::string_view str_view(std::get(line)); m_log_text->appendHtml( - QStringLiteral("%1 %3") + QStringLiteral("%1%3") .arg(QStringFromStringView(str_view.substr(0, TIMESTAMP_LENGTH)), QString::fromUtf8(color), QStringFromStringView(str_view.substr(TIMESTAMP_LENGTH)).toHtmlEscaped()));