su  1.12.11devel
su_debug.h
Go to the documentation of this file.
1 /*
2  * This file is part of the Sofia-SIP package
3  *
4  * Copyright (C) 2005 Nokia Corporation.
5  *
6  * Contact: Pekka Pessi <pekka.pessi@nokia-email.address.hidden>
7  *
8  * This library is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU Lesser General Public License
10  * as published by the Free Software Foundation; either version 2.1 of
11  * the License, or (at your option) any later version.
12  *
13  * This library is distributed in the hope that it will be useful, but
14  * WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16  * Lesser General Public License for more details.
17  *
18  * You should have received a copy of the GNU Lesser General Public
19  * License along with this library; if not, write to the Free Software
20  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
21  * 02110-1301 USA
22  *
23  */
24 
25 #ifndef SU_DEBUG_H
26 
27 #define SU_DEBUG_H
28 
53 #ifndef SU_LOG_H
54 #include <sofia-sip/su_log.h>
55 #endif
56 
57 SOFIA_BEGIN_DECLS
58 
59 #ifndef SU_DEBUG_MAX
60 
61 #define SU_DEBUG_MAX 9
62 #endif
63 
64 #define SU_LOG_LEVEL \
65 ((SU_LOG->log_init) == 0 ? 9 : \
66 ((SU_LOG->log_init > 1) ? SU_LOG->log_level : su_log_default->log_level))
67 
68 #if SU_DEBUG_MAX >= 0
69 #ifndef SU_LOG
70 #define SU_LOG (su_log_default)
71 #else
72 SOFIAPUBVAR su_log_t SU_LOG[];
73 #endif
74 
75 #define SU_DEBUG_DEF(level) \
76  su_inline void su_debug_##level(char const *fmt, ...) \
77  __attribute__ ((__format__ (printf, 1, 2))); \
78  su_inline void su_debug_##level(char const *fmt, ...) \
79  { va_list ap; va_start(ap, fmt); su_vllog(SU_LOG, level, fmt, ap); va_end(ap); }
80 
81 SU_DEBUG_DEF(0)
88 #define SU_DEBUG_0(x) (su_debug_0 x)
89 
91 #define SU_LERROR(s) (su_llog(SU_LOG, 1, "%s: %s\n", (s), strerror(errno)))
92 
93 #define SU_LSERROR(s) \
94  (su_llog(SU_LOG, 1, "%s: %s\n", (s), su_strerror(su_errno())))
95 #else
96 #define SU_DEBUG_0(x) ((void)0)
97 #define SU_LERROR(s) ((void)0)
98 #define SU_LSERROR(s) ((void)0)
99 #endif
100 
101 #if SU_DEBUG_MAX >= 1
102 SU_DEBUG_DEF(1)
110 #define SU_DEBUG_1(x) (SU_LOG_LEVEL >= 1 ? (su_debug_1 x) : (void)0)
111 #else
112 #define SU_DEBUG_1(x) (void)1
113 #endif
114 
115 #if SU_DEBUG_MAX >= 2
116 SU_DEBUG_DEF(2)
123 #define SU_DEBUG_2(x) (SU_LOG_LEVEL >= 2 ? (su_debug_2 x) : (void)0)
124 #else
125 #define SU_DEBUG_2(x) (void)2
126 #endif
127 
128 #if SU_DEBUG_MAX >= 3
129 SU_DEBUG_DEF(3)
136 #define SU_DEBUG_3(x) (SU_LOG_LEVEL >= 3 ? (su_debug_3 x) : (void)0)
137 #else
138 #define SU_DEBUG_3(x) (void)3
139 #endif
140 
141 #if SU_DEBUG_MAX >= 4
142 SU_DEBUG_DEF(4)
144 #define SU_DEBUG_4(x) (SU_LOG_LEVEL >= 4 ? (su_debug_4 x) : (void)0)
145 #else
146 #define SU_DEBUG_4(x) (void)4
147 #endif
148 
149 #if SU_DEBUG_MAX >= 5
150 SU_DEBUG_DEF(5)
158 #define SU_DEBUG_5(x) (SU_LOG_LEVEL >= 5 ? (su_debug_5 x) : (void)0)
159 #else
160 #define SU_DEBUG_5(x) (void)5
161 #endif
162 
163 #if SU_DEBUG_MAX >= 6
164 SU_DEBUG_DEF(6)
166 #define SU_DEBUG_6(x) (SU_LOG_LEVEL >= 6 ? (su_debug_6 x) : (void)0)
167 #else
168 #define SU_DEBUG_6(x) (void)6
169 #endif
170 
171 #if SU_DEBUG_MAX >= 7
172 SU_DEBUG_DEF(7)
179 #define SU_DEBUG_7(x) (SU_LOG_LEVEL >= 7 ? (su_debug_7 x) : (void)0)
180 #else
181 #define SU_DEBUG_7(x) (void)7
182 #endif
183 
184 #if SU_DEBUG_MAX >= 8
185 SU_DEBUG_DEF(8)
187 #define SU_DEBUG_8(x) (SU_LOG_LEVEL >= 8 ? (su_debug_8 x) : (void)0)
188 #else
189 #define SU_DEBUG_8(x) (void)8
190 #endif
191 
192 #if SU_DEBUG_MAX >= 9
193 SU_DEBUG_DEF(9)
201 #define SU_DEBUG_9(x) (SU_LOG_LEVEL >= 9 ? (su_debug_9 x) : (void)0)
202 #else
203 #define SU_DEBUG_9(x) (void)9
204 #endif
205 
206 SOFIA_END_DECLS
207 
208 #endif /* SU_DEBUG_H */
SU logging interface.
#define SOFIAPUBVAR
SOFIAPUBVAR declares an exported variable.
Definition: su_config.h:68
Log object.
Definition: su_log.h:59

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