diff common/logging.h @ 329:b1059360a0c7

Debugprintf with output debug string on windows. Makes debugging with redirectred input easier
author Andre Heinecke <aheinecke@intevation.de>
date Tue, 08 Apr 2014 14:52:31 +0000
parents b033b16dd290
children 17e1c8f37d72
line wrap: on
line diff
--- a/common/logging.h	Tue Apr 08 14:50:31 2014 +0000
+++ b/common/logging.h	Tue Apr 08 14:52:31 2014 +0000
@@ -51,29 +51,21 @@
  * Prints to stderr if DEBUGOUTPUT is defined.
  */
 #ifdef DEBUGOUTPUT
-#define DEBUGPRINTF(fmt, ...) fprintf(stderr, DEBUGPREFIX "DEBUG: " fmt, ##__VA_ARGS__);
-#else
-#define DEBUGPRINTF(fmt, ...)
-#endif
-
-/**
- * @def DEBUGMSG(msg)
- * @brief Prints a static debug message
- *
- * If DEBUGOUTPUT is defined this. Prints a debug message
- * to stdout on Unix systems. On Windows OutputDebugString is used.
- */
-#ifdef DEBUGOUTPUT
-# ifdef WIN32
-#  define DEBUGMSG(msg) OutputDebugString (msg);
-# else
-#  define DEBUGMSG(msg) printf (DEBUGPREFIX "DEBUG: " msg "\n");
-# endif
+# ifndef WIN32
+#  define DEBUGPRINTF(fmt, ...) fprintf(stderr, DEBUGPREFIX "DEBUG: " fmt, ##__VA_ARGS__);
+# else /* WIN32 */
+#  define DEBUGPRINTF(fmt, ...) \
+  { \
+    char buf[512]; \
+    snprintf(buf, 511, "DEBUG: " fmt, ##__VA_ARGS__); \
+    buf[511] = '\0'; \
+    OutputDebugStringA(buf); \
+  }
+# endif /* WIN32 */
 #else
 # define DEBUGPRINTF(fmt, ...)
 #endif
 
-
 /**
  * @def ERRORPRINTF(fmt, ...)
  * @brief Debug printf

http://wald.intevation.org/projects/trustbridge/