2 ** Copyright 2002, Thomas Kurschel. All rights reserved.
3 ** Distributed under the terms of the NewOS License.
6 #ifndef __DEBUG_EXT_H__
7 #define __DEBUG_EXT_H__
9 // this is a dprintf wrapper
11 // there are three kinds of messages:
12 // flow: used to trace execution
13 // info: tells things that are important but not an error
14 // error: used if something has gone wrong
17 // SHOW_{FLOW,INFO,ERROR}( seriousness, format string, parameters... );
18 // SHOW_{FLOW,INFO,ERROR}0( seriousness, string );
21 // seriousness: the smaller the more serious (0..3)
22 // format string, parameters: normal printf stuff
24 // to specify the module that created the message you have
25 // to define a string called
27 // you dynamically speficify the maximum seriousness level by defining
28 // the following variables/macros
33 // you _can_ statically specify the maximum seriuosness level by defining
34 // DEBUG_MAX_LEVEL_FLOW
35 // DEBUG_MAX_LEVEL_INFO
36 // DEBUG_MAX_LEVEL_ERRROR
38 // you _can_ ask to delay execution after each printed message
39 // by defining the duration (in ms) via
40 // DEBUG_WAIT_ON_MSG (for flow and info)
41 // DEBUG_WAIT_ON_ERROR (for error)
43 #ifdef DEBUG_WAIT_ON_MSG
44 #define DEBUG_WAIT thread_snooze( DEBUG_WAIT_ON_MSG );
49 #ifdef DEBUG_WAIT_ON_ERROR
50 #define DEBUG_WAIT_ERROR thread_snooze( DEBUG_WAIT_ON_ERROR );
52 #define DEBUG_WAIT_ERROR
55 #ifndef DEBUG_MAX_LEVEL_FLOW
56 #define DEBUG_MAX_LEVEL_FLOW 255
59 #ifndef DEBUG_MAX_LEVEL_INFO
60 #define DEBUG_MAX_LEVEL_INFO 255
63 #ifndef DEBUG_MAX_LEVEL_ERROR
64 #define DEBUG_MAX_LEVEL_ERROR 255
67 #ifndef DEBUG_MSG_PREFIX
68 #error you need to define DEBUG_MSG_PREFIX with the module name
71 #define FUNC_NAME DEBUG_MSG_PREFIX, __FUNCTION__, ": "
73 #define SHOW_FLOW(seriousness, format, param...) \
74 do { if( seriousness <= debug_level_flow && seriousness <= DEBUG_MAX_LEVEL_FLOW ) { \
75 dprintf( "%s%s%s"format"\n", FUNC_NAME, param ); DEBUG_WAIT \
78 #define SHOW_FLOW0(seriousness, format) \
79 do { if( seriousness <= debug_level_flow && seriousness <= DEBUG_MAX_LEVEL_FLOW ) { \
80 dprintf( "%s%s%s"format"\n", FUNC_NAME); DEBUG_WAIT \
83 #define SHOW_INFO(seriousness, format, param...) \
84 do { if( seriousness <= debug_level_info && seriousness <= DEBUG_MAX_LEVEL_INFO ) { \
85 dprintf( "%s%s%s"format"\n", FUNC_NAME, param ); DEBUG_WAIT \
88 #define SHOW_INFO0(seriousness, format) \
89 do { if( seriousness <= debug_level_info && seriousness <= DEBUG_MAX_LEVEL_INFO ) { \
90 dprintf( "%s%s%s"format"\n", FUNC_NAME); DEBUG_WAIT \
93 #define SHOW_ERROR(seriousness, format, param...) \
94 do { if( seriousness <= debug_level_error && seriousness <= DEBUG_MAX_LEVEL_ERROR ) { \
95 dprintf( "%s%s%s"format"\n", FUNC_NAME, param ); DEBUG_WAIT_ERROR \
98 #define SHOW_ERROR0(seriousness, format) \
99 do { if( seriousness <= debug_level_error && seriousness <= DEBUG_MAX_LEVEL_ERROR ) { \
100 dprintf( "%s%s%s"format"\n", FUNC_NAME); DEBUG_WAIT_ERROR \