comparison src/debug.h @ 507:135570a8bd96

Move debug macros from main.h to new debug.h. Make debug_level static to debug.c and add utility functions to manipulate it. Add #include "debug.h" where needed.
author zas_
date Thu, 24 Apr 2008 08:53:39 +0000
parents
children b78a91d0779e
comparison
equal deleted inserted replaced
506:fc9c8a3e1a8b 507:135570a8bd96
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);
30
31 #define DEBUG_N(n, ...) do \
32 { \
33 gint debug_level = get_debug_level(); \
34 if (debug_level >= (n)) \
35 { \
36 if (debug_level != 1) printf("%s:%d: ", __FILE__, __LINE__); \
37 printf(__VA_ARGS__); \
38 putchar('\n'); \
39 } \
40 } while (0)
41 #else
42
43 #define get_debug_level() (0)
44 #define set_debug_level(new_level) do { } while(0)
45 #define debug_level_add(delta) do { } while(0)
46 #define required_debug_level(level) (0)
47 #define DEBUG_N(n, ...) do { } while(0)
48
49 #endif
50
51 #define DEBUG_0(...) DEBUG_N(0, __VA_ARGS__)
52 #define DEBUG_1(...) DEBUG_N(1, __VA_ARGS__)
53 #define DEBUG_2(...) DEBUG_N(2, __VA_ARGS__)
54 #define DEBUG_3(...) DEBUG_N(3, __VA_ARGS__)
55 #define DEBUG_4(...) DEBUG_N(4, __VA_ARGS__)
56
57
58 #endif /* DEBUG_H */