Skip to content

Commit

Permalink
[Logger] Enable logging to VS output window
Browse files Browse the repository at this point in the history
  • Loading branch information
pzychotic committed Oct 27, 2024
1 parent 73d2764 commit e88fe18
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion logger/log.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
#include <plog/Initializers/RollingFileInitializer.h>

#ifdef WIN32
#include <plog/Appenders/DebugOutputAppender.h>
#include <cstdio>
#include <windows.h>
#include "debug.h"
Expand All @@ -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());

#ifdef WIN32
static plog::DebugOutputAppender<plog::TxtFormatter> debugAppender;

if (enable_win_console) {
// Open console window
AllocConsole();
Expand All @@ -53,4 +56,9 @@ void InitLog(plog::Severity log_level, bool enable_filelog, bool enable_win_cons
}
plog::get()->addAppender(&fileAppender);
}
}
#ifdef WIN32
if (IsDebuggerPresent()) {
plog::get()->addAppender(&debugAppender);
}
#endif
}

0 comments on commit e88fe18

Please sign in to comment.