From 0759c087b18b3ccc54f7393f426a5e19ce49aeb8 Mon Sep 17 00:00:00 2001 From: "Bernhart, Bryan" Date: Fri, 17 Feb 2023 14:27:25 -0800 Subject: [PATCH] Ignore MessageId in log messages when unknown. --- src/gpgmm/utils/Log.cpp | 25 +++++++++++++++++++------ 1 file changed, 19 insertions(+), 6 deletions(-) diff --git a/src/gpgmm/utils/Log.cpp b/src/gpgmm/utils/Log.cpp index 5bfd02781..d06863c05 100644 --- a/src/gpgmm/utils/Log.cpp +++ b/src/gpgmm/utils/Log.cpp @@ -119,10 +119,18 @@ namespace gpgmm { // where users could see it, since users don't understand these messages anyway. #if defined(GPGMM_PLATFORM_WINDOWS) if (IsDebuggerPresent()) { - const std::string outputString = - std::string(kLogTag) + " " + std::string(severityName) + - "(tid: " + ToString(std::this_thread::get_id()) + "): " + fullMessage + "(" + - ToString(static_cast(mMessageId)) + ")" + "\n"; + std::string outputString; + if (mMessageId != MessageId::kUnknown) { + outputString = + std::string(kLogTag) + " " + std::string(severityName) + + "(tid: " + ToString(std::this_thread::get_id()) + "): " + fullMessage + + "(MessageId=" + ToString(static_cast(mMessageId)) + ")" + "\n"; + } else { + outputString = std::string(kLogTag) + " " + std::string(severityName) + + "(tid: " + ToString(std::this_thread::get_id()) + + "): " + fullMessage + "\n"; + } + OutputDebugStringA(outputString.c_str()); } #endif // defined(GPGMM_PLATFORM_WINDOWS) @@ -138,8 +146,13 @@ namespace gpgmm { fullMessage.c_str()); #else // defined(GPGMM_PLATFORM_ANDROID) // Note: we use fprintf because includes static initializers. - fprintf(outputStream, "%s %s (tid:%s): %s (%d)\n", kLogTag, severityName, - ToString(std::this_thread::get_id()).c_str(), fullMessage.c_str(), mMessageId); + if (mMessageId != MessageId::kUnknown) { + fprintf(outputStream, "%s %s (tid:%s): %s (MessageId=%d)\n", kLogTag, severityName, + ToString(std::this_thread::get_id()).c_str(), fullMessage.c_str(), mMessageId); + } else { + fprintf(outputStream, "%s %s (tid:%s): %s\n", kLogTag, severityName, + ToString(std::this_thread::get_id()).c_str(), fullMessage.c_str()); + } fflush(outputStream); #endif }