su 1.12.11devel
/tmp/buildd/sofia-sip-1.12.11+20110422/libsofia-sip-ua/su/sofia-sip/su_debug.h
Go to the documentation of this file.
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->log_init) == 0 ? 9 : \
00066 ((SU_LOG->log_init > 1) ? SU_LOG->log_level : su_log_default->log_level))
00067 
00068 #if SU_DEBUG_MAX >= 0
00069 #ifndef SU_LOG
00070 #define SU_LOG       (su_log_default)
00071 #else
00072 SOFIAPUBVAR su_log_t SU_LOG[];
00073 #endif
00074 
00075 #define SU_DEBUG_DEF(level) \
00076   su_inline void su_debug_##level(char const *fmt, ...) \
00077     __attribute__ ((__format__ (printf, 1, 2))); \
00078   su_inline void su_debug_##level(char const *fmt, ...) \
00079     { va_list ap; va_start(ap, fmt); su_vllog(SU_LOG, level, fmt, ap); va_end(ap); }
00080 
00081 SU_DEBUG_DEF(0)
00088 #define SU_DEBUG_0(x) (su_debug_0 x)
00089 
00091 #define SU_LERROR(s) (su_llog(SU_LOG, 1, "%s: %s\n", (s), strerror(errno)))
00092 
00093 #define SU_LSERROR(s) \
00094   (su_llog(SU_LOG, 1, "%s: %s\n", (s), su_strerror(su_errno())))
00095 #else
00096 #define SU_DEBUG_0(x) ((void)0)
00097 #define SU_LERROR(s)  ((void)0)
00098 #define SU_LSERROR(s) ((void)0)
00099 #endif
00100 
00101 #if SU_DEBUG_MAX >= 1
00102 SU_DEBUG_DEF(1)
00110 #define SU_DEBUG_1(x) (SU_LOG_LEVEL >= 1 ? (su_debug_1 x) : (void)0)
00111 #else
00112 #define SU_DEBUG_1(x) (void)1
00113 #endif
00114 
00115 #if SU_DEBUG_MAX >= 2
00116 SU_DEBUG_DEF(2)
00123 #define SU_DEBUG_2(x) (SU_LOG_LEVEL >= 2 ? (su_debug_2 x) : (void)0)
00124 #else
00125 #define SU_DEBUG_2(x) (void)2
00126 #endif
00127 
00128 #if SU_DEBUG_MAX >= 3
00129 SU_DEBUG_DEF(3)
00136 #define SU_DEBUG_3(x) (SU_LOG_LEVEL >= 3 ? (su_debug_3 x) : (void)0)
00137 #else
00138 #define SU_DEBUG_3(x) (void)3
00139 #endif
00140 
00141 #if SU_DEBUG_MAX >= 4
00142 SU_DEBUG_DEF(4)
00144 #define SU_DEBUG_4(x) (SU_LOG_LEVEL >= 4 ? (su_debug_4 x) : (void)0)
00145 #else
00146 #define SU_DEBUG_4(x) (void)4
00147 #endif
00148 
00149 #if SU_DEBUG_MAX >= 5
00150 SU_DEBUG_DEF(5)
00158 #define SU_DEBUG_5(x) (SU_LOG_LEVEL >= 5 ? (su_debug_5 x) : (void)0)
00159 #else
00160 #define SU_DEBUG_5(x) (void)5
00161 #endif
00162 
00163 #if SU_DEBUG_MAX >= 6
00164 SU_DEBUG_DEF(6)
00166 #define SU_DEBUG_6(x) (SU_LOG_LEVEL >= 6 ? (su_debug_6 x) : (void)0)
00167 #else
00168 #define SU_DEBUG_6(x) (void)6
00169 #endif
00170 
00171 #if SU_DEBUG_MAX >= 7
00172 SU_DEBUG_DEF(7)
00179 #define SU_DEBUG_7(x) (SU_LOG_LEVEL >= 7 ? (su_debug_7 x) : (void)0)
00180 #else
00181 #define SU_DEBUG_7(x) (void)7
00182 #endif
00183 
00184 #if SU_DEBUG_MAX >= 8
00185 SU_DEBUG_DEF(8)
00187 #define SU_DEBUG_8(x) (SU_LOG_LEVEL >= 8 ? (su_debug_8 x) : (void)0)
00188 #else
00189 #define SU_DEBUG_8(x) (void)8
00190 #endif
00191 
00192 #if SU_DEBUG_MAX >= 9
00193 SU_DEBUG_DEF(9)
00201 #define SU_DEBUG_9(x) (SU_LOG_LEVEL >= 9 ? (su_debug_9 x) : (void)0)
00202 #else
00203 #define SU_DEBUG_9(x) (void)9
00204 #endif
00205 
00206 SOFIA_END_DECLS
00207 
00208 #endif /* SU_DEBUG_H */
 All Data Structures Files Functions Variables Typedefs Enumerator Defines

Sofia-SIP 1.12.11devel - Copyright (C) 2006 Nokia Corporation. All rights reserved. Licensed under the terms of the GNU Lesser General Public License.