Skip to content

Commit a92a696

Browse files
committed
Log debug messages to stdout as well, and fixed release build LogDebug macro.
1 parent 257b797 commit a92a696

File tree

3 files changed

+6
-1
lines changed

3 files changed

+6
-1
lines changed

include/Log.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,5 @@ void Log(const char* prefix, const char* format, ...);
55
#if _DEBUG
66
#define LogDebug(...) Log("DEBUG: ", __VA_ARGS__)
77
#else
8-
#define LogDebug(...) (void)
8+
#define LogDebug(...)
99
#endif

source/Log.cpp

+2
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,13 @@
77
void Log(const char* prefix, const char* format, ...)
88
{
99
va_list args;
10+
printf("%s", prefix);
1011
OutputDebugString(prefix);
1112
va_start(args, format);
1213
int count = _vscprintf(format, args);
1314
char* buffer = (char*)_alloca(count + 1);
1415
vsprintf_s(buffer, count + 1, format, args);
1516
OutputDebugString(buffer);
17+
printf(buffer);
1618
va_end(args);
1719
}

source/main.cpp

+3
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
#include <string>
1111
#include "Error.h"
1212
#include "SaveRestoreConsole.h"
13+
#include "Log.h"
1314

1415
using namespace std;
1516

@@ -25,6 +26,8 @@ static void DisplayHelp()
2526

2627
int main(int argc, char** argv)
2728
{
29+
LogDebug("main\n");
30+
2831
#if defined(_DEBUG)
2932
_CrtSetDbgFlag(_CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF);
3033
#endif

0 commit comments

Comments
 (0)