upleb.uk

Public git repos — served from a NIP-34 GRASP relay at git.upleb.uk

summaryrefslogtreecommitdiff
path: root/src/util.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/util.h')
-rw-r--r--src/util.h35
1 files changed, 24 insertions, 11 deletions
diff --git a/src/util.h b/src/util.h
index 96cb4d4..c53293a 100644
--- a/src/util.h
+++ b/src/util.h
@@ -231,11 +231,28 @@ void PrintHex(const T pbegin, const T pend, const char* pszFormat="%s", bool fSp
231 231
232 232
233 233
234// Forward declaration — defined in main.cpp
235string GetAppDir();
236
234inline int OutputDebugStringF(const char* pszFormat, ...) 237inline int OutputDebugStringF(const char* pszFormat, ...)
235{ 238{
236#if 1 // debug.log always enabled (was previously only under __WXDEBUG__) 239#if 1 // debug.log always enabled
237 // log file 240 // Write to data directory so it's always findable
238 FILE* fileout = fopen("debug.log", "a"); 241 static string strDebugFile;
242 if (strDebugFile.empty()) {
243 string dir = GetAppDir();
244 if (!dir.empty())
245 strDebugFile = dir +
246#ifdef _WIN32
247 "\\"
248#else
249 "/"
250#endif
251 + "debug.log";
252 else
253 strDebugFile = "debug.log";
254 }
255 FILE* fileout = fopen(strDebugFile.c_str(), "a");
239 if (fileout) 256 if (fileout)
240 { 257 {
241 va_list arg_ptr; 258 va_list arg_ptr;
@@ -296,14 +313,10 @@ inline int OutputDebugStringF(const char* pszFormat, ...)
296 } 313 }
297#endif 314#endif
298 315
299 if (!wxTheApp) 316 va_list arg_ptr;
300 { 317 va_start(arg_ptr, pszFormat);
301 // print to console 318 vprintf(pszFormat, arg_ptr);
302 va_list arg_ptr; 319 va_end(arg_ptr);
303 va_start(arg_ptr, pszFormat);
304 vprintf(pszFormat, arg_ptr);
305 va_end(arg_ptr);
306 }
307 return 0; 320 return 0;
308} 321}
309 322