diff --git a/app/MyApp.cpp b/app/MyApp.cpp index f7079bf..604a4e7 100644 --- a/app/MyApp.cpp +++ b/app/MyApp.cpp @@ -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(); } diff --git a/util/MyDebug.h b/util/MyDebug.h index 20e3af3..79cf983 100644 --- a/util/MyDebug.h +++ b/util/MyDebug.h @@ -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