[Logger] Enable logging to VS output window

This commit is contained in:
Thomas Roß 2024-10-27 16:09:06 +01:00
parent 73d2764573
commit e88fe1845a

View File

@ -22,6 +22,7 @@
#include <plog/Initializers/RollingFileInitializer.h> #include <plog/Initializers/RollingFileInitializer.h>
#ifdef WIN32 #ifdef WIN32
#include <plog/Appenders/DebugOutputAppender.h>
#include <cstdio> #include <cstdio>
#include <windows.h> #include <windows.h>
#include "debug.h" #include "debug.h"
@ -35,6 +36,8 @@ void InitLog(plog::Severity log_level, bool enable_filelog, bool enable_win_cons
static plog::RollingFileAppender<plog::TxtFormatter> fileAppender(log_file.u8string().c_str()); static plog::RollingFileAppender<plog::TxtFormatter> fileAppender(log_file.u8string().c_str());
#ifdef WIN32 #ifdef WIN32
static plog::DebugOutputAppender<plog::TxtFormatter> debugAppender;
if (enable_win_console) { if (enable_win_console) {
// Open console window // Open console window
AllocConsole(); AllocConsole();
@ -53,4 +56,9 @@ void InitLog(plog::Severity log_level, bool enable_filelog, bool enable_win_cons
} }
plog::get()->addAppender(&fileAppender); plog::get()->addAppender(&fileAppender);
} }
} #ifdef WIN32
if (IsDebuggerPresent()) {
plog::get()->addAppender(&debugAppender);
}
#endif
}