Commit | Line | Data |
---|---|---|
bc97a989 LM |
1 | #ifndef __DEBUG_H__ |
2 | #define __DEBUG_H__ | |
3 | ||
11a49e35 LM |
4 | #include "color.h" |
5 | ||
bc97a989 LM |
6 | /* constants */ |
7 | ||
c7f2604b LM |
8 | #define DEBUG 3 |
9 | #define INFO 2 | |
bc97a989 | 10 | #define WARNING 1 |
c7f2604b LM |
11 | #define ERROR 0 |
12 | ||
bc97a989 LM |
13 | /* macros */ |
14 | ||
c7f2604b LM |
15 | #define VERBOSE(level, statement...) \ |
16 | do { if (level <= verbose) { CHANGE_COLOR(level); statement; CHANGE_COLOR(-1); } } while(0) | |
bc97a989 | 17 | |
c7f2604b | 18 | #define CHANGE_COLOR(level) \ |
11a49e35 LM |
19 | color_set ((level == ERROR) ? stderr : stdout, \ |
20 | (level == ERROR) ? FG_RED : \ | |
21 | (level == WARNING) ? FG_YELLOW : \ | |
22 | (level == INFO) ? FG_BLUE : \ | |
23 | (level == DEBUG) ? FG_GREEN : COLOR_DEFAULT) | |
c7f2604b | 24 | |
bc97a989 LM |
25 | /* gobal variables */ |
26 | ||
27 | extern int verbose; | |
28 | ||
29 | #endif /* __DEBUG_H__ */ | |
30 | ||
4b16fb43 | 31 | /* vim: set ts=4 sw=4 et: */ |