Mercurial > geeqie.yaz
annotate src/debug.h @ 967:eb5dbdff14f6
Move variable declaration at start of block.
author | zas_ |
---|---|
date | Sun, 17 Aug 2008 09:00:33 +0000 |
parents | c0dda0ffb931 |
children | 4fe8f9656107 |
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 | |
686 | 12 #ifndef _DEBUG_H |
13 #define _DEBUG_H | |
14 | |
15 #include <glib.h> | |
507 | 16 |
673
fbebf5cf4a55
Do not use printf() directly but use new wrapper function log_printf() instead.
zas_
parents:
509
diff
changeset
|
17 #define DOMAIN_DEBUG "debug" |
fbebf5cf4a55
Do not use printf() directly but use new wrapper function log_printf() instead.
zas_
parents:
509
diff
changeset
|
18 #define DOMAIN_INFO "info" |
fbebf5cf4a55
Do not use printf() directly but use new wrapper function log_printf() instead.
zas_
parents:
509
diff
changeset
|
19 |
fbebf5cf4a55
Do not use printf() directly but use new wrapper function log_printf() instead.
zas_
parents:
509
diff
changeset
|
20 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
|
21 #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
|
22 |
507 | 23 #ifdef DEBUG |
24 | |
25 #define DEBUG_LEVEL_MIN 0 | |
26 #define DEBUG_LEVEL_MAX 4 | |
27 | |
28 gint get_debug_level(void); | |
29 void set_debug_level(gint new_level); | |
30 void debug_level_add(gint delta); | |
31 gint required_debug_level(gint level); | |
509 | 32 const gchar *get_exec_time(void); |
33 void init_exec_time(void); | |
507 | 34 |
35 #define DEBUG_N(n, ...) do \ | |
36 { \ | |
37 gint debug_level = get_debug_level(); \ | |
38 if (debug_level >= (n)) \ | |
39 { \ | |
673
fbebf5cf4a55
Do not use printf() directly but use new wrapper function log_printf() instead.
zas_
parents:
509
diff
changeset
|
40 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
|
41 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
|
42 log_domain_printf(DOMAIN_DEBUG, "\n"); \ |
507 | 43 } \ |
44 } while (0) | |
509 | 45 |
46 #else /* DEBUG */ | |
507 | 47 |
48 #define get_debug_level() (0) | |
49 #define set_debug_level(new_level) do { } while(0) | |
50 #define debug_level_add(delta) do { } while(0) | |
51 #define required_debug_level(level) (0) | |
509 | 52 #define get_exec_time() "" |
53 #define init_exec_time() do { } while(0) | |
54 | |
507 | 55 #define DEBUG_N(n, ...) do { } while(0) |
56 | |
509 | 57 #endif /* DEBUG */ |
507 | 58 |
59 #define DEBUG_0(...) DEBUG_N(0, __VA_ARGS__) | |
60 #define DEBUG_1(...) DEBUG_N(1, __VA_ARGS__) | |
61 #define DEBUG_2(...) DEBUG_N(2, __VA_ARGS__) | |
62 #define DEBUG_3(...) DEBUG_N(3, __VA_ARGS__) | |
63 #define DEBUG_4(...) DEBUG_N(4, __VA_ARGS__) | |
64 | |
65 | |
686 | 66 #endif /* _DEBUG_H */ |