QsLog: Fix Windows console output

This commit is contained in:
Felix Kauselmann 2023-04-22 20:13:45 +02:00
parent 0ead759364
commit 6899bfbcf1

View File

@ -31,17 +31,18 @@
#include <cstdio> #include <cstdio>
void QsDebugOutput::output( const QString& message ) void QsDebugOutput::output( const QString& message )
{ {
fprintf(stderr, "%s\n", qPrintable(message)); fprintf(stderr, "%s\n", qPrintable(message));
fflush(stderr); fflush(stderr);
} }
#elif defined(Q_OS_WIN) #elif defined(Q_OS_WIN)
#define WIN32_LEAN_AND_MEAN #define WIN32_LEAN_AND_MEAN
#include <windows.h> #include <Windows.h>
void QsDebugOutput::output( const QString& message ) void QsDebugOutput::output( const QString& message )
{ {
OutputDebugStringW(reinterpret_cast<const WCHAR*>(message.utf16())); WriteConsoleW(GetStdHandle(STD_ERROR_HANDLE), message.utf16(), message.size(), NULL, NULL);
OutputDebugStringW(L"\n"); WriteConsoleW(GetStdHandle(STD_ERROR_HANDLE), L"\n", 1, NULL, NULL);
} }
#endif #endif
const char* const QsLogging::DebugOutputDestination::Type = "console"; const char* const QsLogging::DebugOutputDestination::Type = "console";