comparison src/debug.h @ 673:fbebf5cf4a55

Do not use printf() directly but use new wrapper function log_printf() instead.
author zas_
date Fri, 16 May 2008 12:16:49 +0000
parents b78a91d0779e
children c0dda0ffb931
comparison
equal deleted inserted replaced
672:913eb0ba99a6 673:fbebf5cf4a55
9 * This software comes with no warranty of any kind, use at your own risk! 9 * This software comes with no warranty of any kind, use at your own risk!
10 */ 10 */
11 11
12 #ifndef DEBUG_H 12 #ifndef DEBUG_H
13 #define DEBUG_H 13 #define DEBUG_H
14
15 #define DOMAIN_DEBUG "debug"
16 #define DOMAIN_INFO "info"
17
18 gint log_domain_printf(const char *domain, const gchar *format, ...) G_GNUC_PRINTF(2, 3);
19 #define log_printf(...) log_domain_printf(DOMAIN_INFO, __VA_ARGS__)
20
21
22
14 23
15 #if 1 /* set to 0 to disable compilation of debugging code and related options */ 24 #if 1 /* set to 0 to disable compilation of debugging code and related options */
16 # ifndef DEBUG 25 # ifndef DEBUG
17 # define DEBUG 1 26 # define DEBUG 1
18 # endif 27 # endif
33 #define DEBUG_N(n, ...) do \ 42 #define DEBUG_N(n, ...) do \
34 { \ 43 { \
35 gint debug_level = get_debug_level(); \ 44 gint debug_level = get_debug_level(); \
36 if (debug_level >= (n)) \ 45 if (debug_level >= (n)) \
37 { \ 46 { \
38 if (debug_level != 1) printf("%s:%d: ", __FILE__, __LINE__); \ 47 if (debug_level != 1) log_domain_printf(DOMAIN_DEBUG, "%s:%d: ", __FILE__, __LINE__); \
39 printf(__VA_ARGS__); \ 48 log_domain_printf(DOMAIN_DEBUG, __VA_ARGS__); \
40 putchar('\n'); \ 49 log_domain_printf(DOMAIN_DEBUG, "\n"); \
41 } \ 50 } \
42 } while (0) 51 } while (0)
43 52
44 #else /* DEBUG */ 53 #else /* DEBUG */
45 54