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
|
|
15 #if 1 /* set to 0 to disable compilation of debugging code and related options */
|
|
16 # ifndef DEBUG
|
|
17 # define DEBUG 1
|
|
18 # endif
|
|
19 #endif
|
|
20
|
|
21 #ifdef DEBUG
|
|
22
|
|
23 #define DEBUG_LEVEL_MIN 0
|
|
24 #define DEBUG_LEVEL_MAX 4
|
|
25
|
|
26 gint get_debug_level(void);
|
|
27 void set_debug_level(gint new_level);
|
|
28 void debug_level_add(gint delta);
|
|
29 gint required_debug_level(gint level);
|
509
|
30 const gchar *get_exec_time(void);
|
|
31 void init_exec_time(void);
|
507
|
32
|
|
33 #define DEBUG_N(n, ...) do \
|
|
34 { \
|
|
35 gint debug_level = get_debug_level(); \
|
|
36 if (debug_level >= (n)) \
|
|
37 { \
|
|
38 if (debug_level != 1) printf("%s:%d: ", __FILE__, __LINE__); \
|
|
39 printf(__VA_ARGS__); \
|
|
40 putchar('\n'); \
|
|
41 } \
|
|
42 } while (0)
|
509
|
43
|
|
44 #else /* DEBUG */
|
507
|
45
|
|
46 #define get_debug_level() (0)
|
|
47 #define set_debug_level(new_level) do { } while(0)
|
|
48 #define debug_level_add(delta) do { } while(0)
|
|
49 #define required_debug_level(level) (0)
|
509
|
50 #define get_exec_time() ""
|
|
51 #define init_exec_time() do { } while(0)
|
|
52
|
507
|
53 #define DEBUG_N(n, ...) do { } while(0)
|
|
54
|
509
|
55 #endif /* DEBUG */
|
507
|
56
|
|
57 #define DEBUG_0(...) DEBUG_N(0, __VA_ARGS__)
|
|
58 #define DEBUG_1(...) DEBUG_N(1, __VA_ARGS__)
|
|
59 #define DEBUG_2(...) DEBUG_N(2, __VA_ARGS__)
|
|
60 #define DEBUG_3(...) DEBUG_N(3, __VA_ARGS__)
|
|
61 #define DEBUG_4(...) DEBUG_N(4, __VA_ARGS__)
|
|
62
|
|
63
|
|
64 #endif /* DEBUG_H */
|