su
1.12.11
|
00001 /* 00002 * This file is part of the Sofia-SIP package 00003 * 00004 * Copyright (C) 2005 Nokia Corporation. 00005 * 00006 * Contact: Pekka Pessi <pekka.pessi@nokia-email.address.hidden> 00007 * 00008 * This library is free software; you can redistribute it and/or 00009 * modify it under the terms of the GNU Lesser General Public License 00010 * as published by the Free Software Foundation; either version 2.1 of 00011 * the License, or (at your option) any later version. 00012 * 00013 * This library is distributed in the hope that it will be useful, but 00014 * WITHOUT ANY WARRANTY; without even the implied warranty of 00015 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00016 * Lesser General Public License for more details. 00017 * 00018 * You should have received a copy of the GNU Lesser General Public 00019 * License along with this library; if not, write to the Free Software 00020 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 00021 * 02110-1301 USA 00022 * 00023 */ 00024 00025 #ifndef SU_DEBUG_H 00026 00027 #define SU_DEBUG_H 00028 00053 #ifndef SU_LOG_H 00054 #include <sofia-sip/su_log.h> 00055 #endif 00056 00057 SOFIA_BEGIN_DECLS 00058 00059 #ifndef SU_DEBUG_MAX 00060 00061 #define SU_DEBUG_MAX 9 00062 #endif 00063 00064 #define SU_LOG_LEVEL \ 00065 ((SU_LOG != NULL && SU_LOG->log_init) == 0 ? 9 : \ 00066 ((SU_LOG != NULL && SU_LOG->log_init > 1) ? \ 00067 SU_LOG->log_level : su_log_default->log_level)) 00068 00069 #if SU_DEBUG_MAX >= 0 00070 #ifndef SU_LOG 00071 #define SU_LOG (su_log_default) 00072 #else 00073 SOFIAPUBVAR su_log_t SU_LOG[]; 00074 #endif 00075 00076 #define SU_DEBUG_DEF(level) \ 00077 su_inline void su_debug_##level(char const *fmt, ...) \ 00078 __attribute__ ((__format__ (printf, 1, 2))); \ 00079 su_inline void su_debug_##level(char const *fmt, ...) \ 00080 { va_list ap; va_start(ap, fmt); su_vllog(SU_LOG, level, fmt, ap); va_end(ap); } 00081 00082 SU_DEBUG_DEF(0) 00089 #define SU_DEBUG_0(x) (SU_LOG_LEVEL >= 0 ? (su_debug_0 x) : (void)0) 00090 00092 #define SU_LERROR(s) (su_llog(SU_LOG, 1, "%s: %s\n", (s), strerror(errno))) 00093 00094 #define SU_LSERROR(s) \ 00095 (su_llog(SU_LOG, 1, "%s: %s\n", (s), su_strerror(su_errno()))) 00096 #else 00097 #define SU_DEBUG_0(x) ((void)0) 00098 #define SU_LERROR(s) ((void)0) 00099 #define SU_LSERROR(s) ((void)0) 00100 #endif 00101 00102 #if SU_DEBUG_MAX >= 1 00103 SU_DEBUG_DEF(1) 00111 #define SU_DEBUG_1(x) (SU_LOG_LEVEL >= 1 ? (su_debug_1 x) : (void)0) 00112 #else 00113 #define SU_DEBUG_1(x) (void)1 00114 #endif 00115 00116 #if SU_DEBUG_MAX >= 2 00117 SU_DEBUG_DEF(2) 00124 #define SU_DEBUG_2(x) (SU_LOG_LEVEL >= 2 ? (su_debug_2 x) : (void)0) 00125 #else 00126 #define SU_DEBUG_2(x) (void)2 00127 #endif 00128 00129 #if SU_DEBUG_MAX >= 3 00130 SU_DEBUG_DEF(3) 00137 #define SU_DEBUG_3(x) (SU_LOG_LEVEL >= 3 ? (su_debug_3 x) : (void)0) 00138 #else 00139 #define SU_DEBUG_3(x) (void)3 00140 #endif 00141 00142 #if SU_DEBUG_MAX >= 4 00143 SU_DEBUG_DEF(4) 00145 #define SU_DEBUG_4(x) (SU_LOG_LEVEL >= 4 ? (su_debug_4 x) : (void)0) 00146 #else 00147 #define SU_DEBUG_4(x) (void)4 00148 #endif 00149 00150 #if SU_DEBUG_MAX >= 5 00151 SU_DEBUG_DEF(5) 00159 #define SU_DEBUG_5(x) (SU_LOG_LEVEL >= 5 ? (su_debug_5 x) : (void)0) 00160 #else 00161 #define SU_DEBUG_5(x) (void)5 00162 #endif 00163 00164 #if SU_DEBUG_MAX >= 6 00165 SU_DEBUG_DEF(6) 00167 #define SU_DEBUG_6(x) (SU_LOG_LEVEL >= 6 ? (su_debug_6 x) : (void)0) 00168 #else 00169 #define SU_DEBUG_6(x) (void)6 00170 #endif 00171 00172 #if SU_DEBUG_MAX >= 7 00173 SU_DEBUG_DEF(7) 00180 #define SU_DEBUG_7(x) (SU_LOG_LEVEL >= 7 ? (su_debug_7 x) : (void)0) 00181 #else 00182 #define SU_DEBUG_7(x) (void)7 00183 #endif 00184 00185 #if SU_DEBUG_MAX >= 8 00186 SU_DEBUG_DEF(8) 00188 #define SU_DEBUG_8(x) (SU_LOG_LEVEL >= 8 ? (su_debug_8 x) : (void)0) 00189 #else 00190 #define SU_DEBUG_8(x) (void)8 00191 #endif 00192 00193 #if SU_DEBUG_MAX >= 9 00194 SU_DEBUG_DEF(9) 00202 #define SU_DEBUG_9(x) (SU_LOG_LEVEL >= 9 ? (su_debug_9 x) : (void)0) 00203 #else 00204 #define SU_DEBUG_9(x) (void)9 00205 #endif 00206 00207 SOFIA_END_DECLS 00208 00209 #endif /* SU_DEBUG_H */