Mercurial > trustbridge
changeset 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 | 18b31e2498a3 |
children | 1e6d1eab8395 |
files | cinst/nssstore_win.c common/logging.h |
diffstat | 2 files changed, 14 insertions(+), 22 deletions(-) [+] |
line wrap: on
line diff
--- a/cinst/nssstore_win.c Tue Apr 08 14:50:31 2014 +0000 +++ b/cinst/nssstore_win.c Tue Apr 08 14:52:31 2014 +0000 @@ -9,6 +9,7 @@ #include <strsafe.h> #include <stdbool.h> #include <userenv.h> +#include <io.h> #include "logging.h" #include "util.h" @@ -20,12 +21,11 @@ #define PRINTLASTERROR(msg) \ char *my_error = getLastErrorMsg(); \ if (my_error) { \ - DEBUGMSG(msg " :"); \ - DEBUGMSG(my_error); \ + DEBUGPRINTF(msg " : %s\n", my_error); \ ERRORPRINTF(msg" : %s\n", my_error); \ free (my_error); \ } \ - DEBUGMSG ("Failed to get error information\n"); + DEBUGPRINTF ("Failed to get error information\n"); /**@brief Write strv of instructions to a handle *
--- 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