Disable logging in non-debug builds

Ideally there would be a preference that allowed you to enable
logging and specify the file's location.  That could make remote
debugging of certain problems easier.
This commit is contained in:
Andy McFadden 2015-01-22 10:06:55 -08:00
parent 5498a4e835
commit a250f6d89a
2 changed files with 11 additions and 2 deletions

View File

@ -18,7 +18,7 @@
MyApp gMyApp;
/* used for debug logging */
DebugLog* gDebugLog;
DebugLog* gDebugLog = NULL;
/*
@ -27,7 +27,10 @@ DebugLog* gDebugLog;
*/
MyApp::MyApp() : CWinAppEx()
{
#ifdef _DEBUG
// TODO: make this a setting, rather than a debug-build-only feature
gDebugLog = new DebugLog(L"C:\\src\\cplog.txt");
#endif
time_t now = time(NULL);
@ -35,12 +38,14 @@ MyApp::MyApp() : CWinAppEx()
kAppMajorVersion, kAppMinorVersion, kAppBugVersion,
kAppDevString, ctime(&now));
#ifdef _DEBUG
int tmpDbgFlag;
// enable memory leak detection
tmpDbgFlag = _CrtSetDbgFlag(_CRTDBG_REPORT_FLAG);
tmpDbgFlag |= _CRTDBG_LEAK_CHECK_DF;
_CrtSetDbgFlag(tmpDbgFlag);
LOGI("Leak detection enabled");
#endif
EnableHtmlHelp();
}

View File

@ -58,7 +58,11 @@ extern DebugLog* gDebugLog; // declare and allocate in app
/* send the message to the log file (if open) and the CRT debug mechanism */
#define LOG_BASE(severity, file, line, format, ...) \
{ gDebugLog->Log((severity), (file), (line), (format), __VA_ARGS__); }
{ \
if (gDebugLog != NULL) { \
gDebugLog->Log((severity), (file), (line), (format), __VA_ARGS__); \
} \
}
/*
* Log macros, with priority specifier. The output will be written to the