Jens Axboe | a3d741f | 2008-02-27 18:32:33 +0100 | [diff] [blame] | 1 | #ifndef FIO_DEBUG_H |
| 2 | #define FIO_DEBUG_H |
| 3 | |
| 4 | #include <assert.h> |
| 5 | #include "log.h" |
| 6 | |
| 7 | enum { |
| 8 | FD_PROCESS = 0, |
| 9 | FD_FILE, |
| 10 | FD_IO, |
| 11 | FD_MEM, |
| 12 | FD_BLKTRACE, |
| 13 | FD_VERIFY, |
| 14 | FD_RANDOM, |
| 15 | FD_PARSE, |
| 16 | FD_DEBUG_MAX, |
| 17 | }; |
| 18 | |
| 19 | #ifdef FIO_INC_DEBUG |
| 20 | struct debug_level { |
| 21 | const char *name; |
| 22 | unsigned long shift; |
| 23 | }; |
| 24 | extern struct debug_level debug_levels[]; |
| 25 | |
| 26 | extern unsigned long fio_debug; |
| 27 | |
| 28 | #define dprint(type, str, args...) \ |
| 29 | do { \ |
| 30 | assert(type < FD_DEBUG_MAX); \ |
| 31 | if ((((1 << type)) & fio_debug) == 0) \ |
| 32 | break; \ |
| 33 | log_info("%-8s ", debug_levels[(type)].name); \ |
| 34 | log_info(str, ##args); \ |
| 35 | } while (0) |
| 36 | |
| 37 | #else |
| 38 | |
| 39 | #define dprint(type, str, args...) |
| 40 | #endif |
| 41 | |
| 42 | #endif |