2 Copyright (c) 2002, Thomas Kurschel
7 Extended debugging functions
11 #ifndef __DEBUG_EXT_H__
12 #define __DEBUG_EXT_H__
14 // this is a dprintf wrapper
16 // there are three kinds of messages:
17 // flow: used to trace execution
18 // info: tells things that are important but not an error
19 // error: used if something has gone wrong
22 // SHOW_{FLOW,INFO,ERROR}( seriousness, format string, parameters... );
23 // SHOW_{FLOW,INFO,ERROR}0( seriousness, string );
26 // seriousness: the smaller the more serious (0..3)
27 // format string, parameters: normal printf stuff
29 // to specify the module that created the message you have
30 // to define a string called
32 // you dynamically speficify the maximum seriousness level by defining
33 // the following variables/macros
38 // you _can_ statically specify the maximum seriuosness level by defining
39 // DEBUG_MAX_LEVEL_FLOW
40 // DEBUG_MAX_LEVEL_INFO
41 // DEBUG_MAX_LEVEL_ERRROR
43 // you _can_ ask to delay execution after each printed message
44 // by defining the duration (in ms) via
45 // DEBUG_WAIT_ON_MSG (for flow and info)
46 // DEBUG_WAIT_ON_ERROR (for error)
48 #ifdef DEBUG_WAIT_ON_MSG
49 #define DEBUG_WAIT snooze( DEBUG_WAIT_ON_MSG );
54 #ifdef DEBUG_WAIT_ON_ERROR
55 #define DEBUG_WAIT_ERROR snooze( DEBUG_WAIT_ON_ERROR );
57 #define DEBUG_WAIT_ERROR
60 #ifndef DEBUG_MAX_LEVEL_FLOW
61 #define DEBUG_MAX_LEVEL_FLOW 4
64 #ifndef DEBUG_MAX_LEVEL_INFO
65 #define DEBUG_MAX_LEVEL_INFO 4
68 #ifndef DEBUG_MAX_LEVEL_ERROR
69 #define DEBUG_MAX_LEVEL_ERROR 4
72 #ifndef DEBUG_MSG_PREFIX
73 #error you need to define DEBUG_MSG_PREFIX with the module name
76 #define FUNC_NAME DEBUG_MSG_PREFIX, __FUNCTION__
78 #define SHOW_FLOW(seriousness, format, param...) \
79 do { if( seriousness <= debug_level_flow && seriousness <= DEBUG_MAX_LEVEL_FLOW ) { \
80 dprintf( "%s%s: " format "\n", FUNC_NAME, param ); DEBUG_WAIT \
83 #define SHOW_FLOW0(seriousness, format) \
84 do { if( seriousness <= debug_level_flow && seriousness <= DEBUG_MAX_LEVEL_FLOW ) { \
85 dprintf( "%s%s: " format "\n", FUNC_NAME); DEBUG_WAIT \
88 #define SHOW_INFO(seriousness, format, param...) \
89 do { if( seriousness <= debug_level_info && seriousness <= DEBUG_MAX_LEVEL_INFO ) { \
90 dprintf( "%s%s: " format "\n", FUNC_NAME, param ); DEBUG_WAIT \
93 #define SHOW_INFO0(seriousness, format) \
94 do { if( seriousness <= debug_level_info && seriousness <= DEBUG_MAX_LEVEL_INFO ) { \
95 dprintf( "%s%s: " format "\n", FUNC_NAME); DEBUG_WAIT \
98 #define SHOW_ERROR(seriousness, format, param...) \
99 do { if( seriousness <= debug_level_error && seriousness <= DEBUG_MAX_LEVEL_ERROR ) { \
100 dprintf( "%s%s: " format "\n", FUNC_NAME, param ); DEBUG_WAIT_ERROR \
103 #define SHOW_ERROR0(seriousness, format) \
104 do { if( seriousness <= debug_level_error && seriousness <= DEBUG_MAX_LEVEL_ERROR ) { \
105 dprintf( "%s%s: " format "\n", FUNC_NAME); DEBUG_WAIT_ERROR \