00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014 #ifndef __LOG_H
00015 #define __LOG_H
00016
00026
00027
00031 void dbg_init(const char *file);
00032
00034
00042 void dbg_log(const int prio, const char *routine, const char *format, ...);
00043
00045
00051 void dbg_level(const int prio, const char *routine);
00052
00053 #define DEBUG_ERROR 0
00054 #define DEBUG_STATE 1
00055 #define DEBUG_COMM 2
00056 #define DEBUG_DATA 3
00057 #define DEBUG_CALLS 4
00058
00060
00061 #ifndef DEBUG_LEVEL
00062 #define DEBUG_LEVEL DEBUG_CALLS
00063 #endif
00064
00065 #ifndef DEBUG_ROUTINE
00066 #define DEBUG_ROUTINE "unknown"
00067 #endif
00068
00070
00071 #define dbg_error(...) dbg_log(DEBUG_ERROR, DEBUG_ROUTINE, __VA_ARGS__)
00072 #define dbg_fatal(...) { dbg_log(DEBUG_ERROR, DEBUG_ROUTINE, __VA_ARGS__); exit(1); }
00073
00075
00076 #if DEBUG_LEVEL >= DEBUG_STATE
00077 #define dbg_state(...) dbg_log(DEBUG_STATE, DEBUG_ROUTINE, __VA_ARGS__)
00078 #else
00079 #define dgb_state(...)
00080 #endif
00081
00083
00084 #if DEBUG_LEVEL >= DEBUG_COMM
00085 #define dbg_comm(...) dbg_log(DEBUG_COMM, DEBUG_ROUTINE, __VA_ARGS__)
00086 #else
00087 #define dbg_comm(...)
00088 #endif
00089
00091
00092 #if DEBUG_LEVEL >= DEBUG_DATA
00093 #define dbg_data(...) dbg_log(DEBUG_DATA, DEBUG_ROUTINE, __VA_ARGS__)
00094 #else
00095 #define dbg_data(...)
00096 #endif
00097
00099
00100 #if DEBUG_LEVEL >= DEBUG_CALLS
00101 #define dbg_calls(...) dbg_log(DEBUG_CALLS, DEBUG_ROUTINE, __VA_ARGS__)
00102 #else
00103 #define dbg_calls(...)
00104 #endif
00105
00106 #endif // __LOG_H