00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025 #ifndef SU_DEBUG_H
00026
00027 #define SU_DEBUG_H
00028
00050 #ifndef SU_LOG_H
00051 #include <sofia-sip/su_log.h>
00052 #endif
00053
00054 SOFIA_BEGIN_DECLS
00055
00056 #ifndef SU_DEBUG_MAX
00057
00058 #define SU_DEBUG_MAX 9
00059 #endif
00060
00061 #define SU_LOG_LEVEL \
00062 ((SU_LOG != NULL && SU_LOG->log_init) == 0 ? 9 : \
00063 ((SU_LOG != NULL && SU_LOG->log_init > 1) ? \
00064 SU_LOG->log_level : su_log_default->log_level))
00065
00066 #ifndef SU_CONFIG_H
00067 #include <sofia-sip/su_config.h>
00068 #endif
00069
00070 #if SU_DEBUG_MAX >= 0
00071 #ifndef SU_LOG
00072 #define SU_LOG (su_log_default)
00073 #else
00074 SOFIAPUBVAR su_log_t SU_LOG[];
00075 #endif
00076
00077 #define SU_DEBUG_DEF(level) \
00078 static SU_INLINE void su_debug_##level(char const *fmt, ...) \
00079 __attribute__ ((__format__ (printf, 1, 2))); \
00080 void su_debug_##level(char const *fmt, ...) \
00081 { va_list ap; va_start(ap, fmt); su_vllog(SU_LOG, level, fmt, ap); va_end(ap); }
00082
00083 SU_DEBUG_DEF(0)
00085 #define SU_DEBUG_0(x) (SU_LOG_LEVEL >= 0 ? (su_debug_0 x) : (void)0)
00086
00088 #define SU_LERROR(s) (su_llog(SU_LOG, 1, "%s: %s\n", (s), strerror(errno)))
00089
00090 #define SU_LSERROR(s) \
00091 (su_llog(SU_LOG, 1, "%s: %s\n", (s), su_strerror(su_errno())))
00092 #else
00093 #define SU_DEBUG_0(x) ((void)0)
00094 #define SU_LERROR(s) ((void)0)
00095 #define SU_LSERROR(s) ((void)0)
00096 #endif
00097
00098 #if SU_DEBUG_MAX >= 1
00099 SU_DEBUG_DEF(1)
00101 #define SU_DEBUG_1(x) (SU_LOG_LEVEL >= 1 ? (su_debug_1 x) : (void)0)
00102 #else
00103 #define SU_DEBUG_1(x) (void)1
00104 #endif
00105
00106 #if SU_DEBUG_MAX >= 2
00107 SU_DEBUG_DEF(2)
00109 #define SU_DEBUG_2(x) (SU_LOG_LEVEL >= 2 ? (su_debug_2 x) : (void)0)
00110 #else
00111 #define SU_DEBUG_2(x) (void)2
00112 #endif
00113
00114 #if SU_DEBUG_MAX >= 3
00115 SU_DEBUG_DEF(3)
00117 #define SU_DEBUG_3(x) (SU_LOG_LEVEL >= 3 ? (su_debug_3 x) : (void)0)
00118 #else
00119 #define SU_DEBUG_3(x) (void)3
00120 #endif
00121
00122 #if SU_DEBUG_MAX >= 4
00123 SU_DEBUG_DEF(4)
00125 #define SU_DEBUG_4(x) (SU_LOG_LEVEL >= 4 ? (su_debug_4 x) : (void)0)
00126 #else
00127 #define SU_DEBUG_4(x) (void)4
00128 #endif
00129
00130 #if SU_DEBUG_MAX >= 5
00131 SU_DEBUG_DEF(5)
00133 #define SU_DEBUG_5(x) (SU_LOG_LEVEL >= 5 ? (su_debug_5 x) : (void)0)
00134 #else
00135 #define SU_DEBUG_5(x) (void)5
00136 #endif
00137
00138 #if SU_DEBUG_MAX >= 6
00139 SU_DEBUG_DEF(6)
00141 #define SU_DEBUG_6(x) (SU_LOG_LEVEL >= 6 ? (su_debug_6 x) : (void)0)
00142 #else
00143 #define SU_DEBUG_6(x) (void)6
00144 #endif
00145
00146 #if SU_DEBUG_MAX >= 7
00147 SU_DEBUG_DEF(7)
00149 #define SU_DEBUG_7(x) (SU_LOG_LEVEL >= 7 ? (su_debug_7 x) : (void)0)
00150 #else
00151 #define SU_DEBUG_7(x) (void)7
00152 #endif
00153
00154 #if SU_DEBUG_MAX >= 8
00155 SU_DEBUG_DEF(8)
00157 #define SU_DEBUG_8(x) (SU_LOG_LEVEL >= 8 ? (su_debug_8 x) : (void)0)
00158 #else
00159 #define SU_DEBUG_8(x) (void)8
00160 #endif
00161
00162 #if SU_DEBUG_MAX >= 9
00163 SU_DEBUG_DEF(9)
00165 #define SU_DEBUG_9(x) (SU_LOG_LEVEL >= 9 ? (su_debug_9 x) : (void)0)
00166 #else
00167 #define SU_DEBUG_9(x) (void)9
00168 #endif
00169
00170 SOFIA_END_DECLS
00171
00172 #endif