comparison common/logging.h @ 524:a097dd86cb4d

merged.
author Raimund Renkert <rrenkert@intevation.de>
date Tue, 29 Apr 2014 15:26:43 +0200
parents 5e2af38266f6
children 2a4f7364ab81
comparison
equal deleted inserted replaced
523:ca583ffe728a 524:a097dd86cb4d
14 14
15 /* 15 /*
16 * @file 16 * @file
17 * @brief Logging and debugging functions 17 * @brief Logging and debugging functions
18 */ 18 */
19
20 #include <stdio.h>
19 21
20 #ifdef WIN32 22 #ifdef WIN32
21 23
22 #include <windows.h> 24 #include <windows.h>
23 25
77 * @def ERRORPRINTF(fmt, ...) 79 * @def ERRORPRINTF(fmt, ...)
78 * @brief Debug printf 80 * @brief Debug printf
79 * 81 *
80 * Prints an error to stderr 82 * Prints an error to stderr
81 */ 83 */
82 #define ERRORPRINTF(fmt, ...) fprintf(stderr, DEBUGPREFIX "ERROR: " fmt, ##__VA_ARGS__); 84 #ifdef WIN32
85 # define ERRORPRINTF(fmt, ...) \
86 { \
87 char buf[512]; \
88 snprintf(buf, 511, "ERROR: " fmt, ##__VA_ARGS__); \
89 buf[511] = '\0'; \
90 OutputDebugStringA(buf); \
91 }
92 #else
93 # define ERRORPRINTF(fmt, ...) fprintf(stderr, DEBUGPREFIX "ERROR: " fmt, ##__VA_ARGS__);
94 #endif
83 95
96 /**
97 * @def PRINTLASTERROR(msg)
98 * @brief Prints the last windows error with a custom message
99 *
100 * Prints an error to stderr
101 */
102 #define PRINTLASTERROR(msg) \
103 char *my_error = getLastErrorMsg(); \
104 if (my_error) { \
105 ERRORPRINTF(msg" : %s\n", my_error); \
106 free (my_error); \
107 } \
108 ERRORPRINTF ("Failed to get error information\n");
84 109
85 110
86 #ifdef __cplusplus 111 #ifdef __cplusplus
87 } 112 }
88 #endif 113 #endif

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