Mercurial > geeqie
annotate 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 |
rev | line source |
---|---|
507 | 1 /* |
2 * Geeqie | |
3 * Copyright (C) 2008 The Geeqie Team | |
4 * | |
5 * Authors: Vladimir Nadvornik, Laurent Monin | |
6 * | |
7 * This software is released under the GNU General Public License (GNU GPL). | |
8 * Please read the included file COPYING for more information. | |
9 * This software comes with no warranty of any kind, use at your own risk! | |
10 */ | |
11 | |
12 #ifndef DEBUG_H | |
13 #define DEBUG_H | |
14 | |
673
fbebf5cf4a55
Do not use printf() directly but use new wrapper function log_printf() instead.
zas_
parents:
509
diff
changeset
|
15 #define DOMAIN_DEBUG "debug" |
fbebf5cf4a55
Do not use printf() directly but use new wrapper function log_printf() instead.
zas_
parents:
509
diff
changeset
|
16 #define DOMAIN_INFO "info" |
fbebf5cf4a55
Do not use printf() directly but use new wrapper function log_printf() instead.
zas_
parents:
509
diff
changeset
|
17 |
fbebf5cf4a55
Do not use printf() directly but use new wrapper function log_printf() instead.
zas_
parents:
509
diff
changeset
|
18 gint log_domain_printf(const char *domain, const gchar *format, ...) G_GNUC_PRINTF(2, 3); |
fbebf5cf4a55
Do not use printf() directly but use new wrapper function log_printf() instead.
zas_
parents:
509
diff
changeset
|
19 #define log_printf(...) log_domain_printf(DOMAIN_INFO, __VA_ARGS__) |
fbebf5cf4a55
Do not use printf() directly but use new wrapper function log_printf() instead.
zas_
parents:
509
diff
changeset
|
20 |
fbebf5cf4a55
Do not use printf() directly but use new wrapper function log_printf() instead.
zas_
parents:
509
diff
changeset
|
21 |
fbebf5cf4a55
Do not use printf() directly but use new wrapper function log_printf() instead.
zas_
parents:
509
diff
changeset
|
22 |
fbebf5cf4a55
Do not use printf() directly but use new wrapper function log_printf() instead.
zas_
parents:
509
diff
changeset
|
23 |
507 | 24 #if 1 /* set to 0 to disable compilation of debugging code and related options */ |
25 # ifndef DEBUG | |
26 # define DEBUG 1 | |
27 # endif | |
28 #endif | |
29 | |
30 #ifdef DEBUG | |
31 | |
32 #define DEBUG_LEVEL_MIN 0 | |
33 #define DEBUG_LEVEL_MAX 4 | |
34 | |
35 gint get_debug_level(void); | |
36 void set_debug_level(gint new_level); | |
37 void debug_level_add(gint delta); | |
38 gint required_debug_level(gint level); | |
509 | 39 const gchar *get_exec_time(void); |
40 void init_exec_time(void); | |
507 | 41 |
42 #define DEBUG_N(n, ...) do \ | |
43 { \ | |
44 gint debug_level = get_debug_level(); \ | |
45 if (debug_level >= (n)) \ | |
46 { \ | |
673
fbebf5cf4a55
Do not use printf() directly but use new wrapper function log_printf() instead.
zas_
parents:
509
diff
changeset
|
47 if (debug_level != 1) log_domain_printf(DOMAIN_DEBUG, "%s:%d: ", __FILE__, __LINE__); \ |
fbebf5cf4a55
Do not use printf() directly but use new wrapper function log_printf() instead.
zas_
parents:
509
diff
changeset
|
48 log_domain_printf(DOMAIN_DEBUG, __VA_ARGS__); \ |
fbebf5cf4a55
Do not use printf() directly but use new wrapper function log_printf() instead.
zas_
parents:
509
diff
changeset
|
49 log_domain_printf(DOMAIN_DEBUG, "\n"); \ |
507 | 50 } \ |
51 } while (0) | |
509 | 52 |
53 #else /* DEBUG */ | |
507 | 54 |
55 #define get_debug_level() (0) | |
56 #define set_debug_level(new_level) do { } while(0) | |
57 #define debug_level_add(delta) do { } while(0) | |
58 #define required_debug_level(level) (0) | |
509 | 59 #define get_exec_time() "" |
60 #define init_exec_time() do { } while(0) | |
61 | |
507 | 62 #define DEBUG_N(n, ...) do { } while(0) |
63 | |
509 | 64 #endif /* DEBUG */ |
507 | 65 |
66 #define DEBUG_0(...) DEBUG_N(0, __VA_ARGS__) | |
67 #define DEBUG_1(...) DEBUG_N(1, __VA_ARGS__) | |
68 #define DEBUG_2(...) DEBUG_N(2, __VA_ARGS__) | |
69 #define DEBUG_3(...) DEBUG_N(3, __VA_ARGS__) | |
70 #define DEBUG_4(...) DEBUG_N(4, __VA_ARGS__) | |
71 | |
72 | |
73 #endif /* DEBUG_H */ |