Output log messages to an attached debugger

This commit is contained in:
Cameron Gutman 2024-06-24 19:24:06 -05:00
parent ac0e1098b9
commit ffdf683597

View file

@ -25,6 +25,9 @@
#if defined(Q_OS_WIN32) #if defined(Q_OS_WIN32)
#include "antihookingprotection.h" #include "antihookingprotection.h"
#define WIN32_LEAN_AND_MEAN
#include <Windows.h>
#elif defined(Q_OS_LINUX) #elif defined(Q_OS_LINUX)
#include <openssl/ssl.h> #include <openssl/ssl.h>
#endif #endif
@ -75,6 +78,18 @@ void logToLoggerStream(QString& message)
{ {
QMutexLocker lock(&s_LoggerLock); QMutexLocker lock(&s_LoggerLock);
#if defined(QT_DEBUG) && defined(Q_OS_WIN32)
// Output log messages to a debugger if attached
if (IsDebuggerPresent()) {
static QString lineBuffer;
lineBuffer += message;
if (message.endsWith('\n')) {
OutputDebugStringW(lineBuffer.toStdWString().c_str());
lineBuffer.clear();
}
}
#endif
// Strip session encryption keys and IVs from the logs // Strip session encryption keys and IVs from the logs
message.replace(k_RikeyRegex, "&rikey=REDACTED"); message.replace(k_RikeyRegex, "&rikey=REDACTED");
message.replace(k_RikeyIdRegex, "&rikeyid=REDACTED"); message.replace(k_RikeyIdRegex, "&rikeyid=REDACTED");