su
1.13.17
sofia-sip
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
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
61
#define SU_DEBUG_MAX 9
62
#endif
63
64
#define SU_LOG_LEVEL \
65
((SU_LOG != NULL && SU_LOG->log_init) == 0 ? 9 : \
66
((SU_LOG != NULL && SU_LOG->log_init > 1) ? \
67
SU_LOG->log_level : su_log_default->log_level))
68
69
#if SU_DEBUG_MAX >= 0
70
#ifndef SU_LOG
71
#define SU_LOG (su_log_default)
72
#else
73
SOFIAPUBVAR
su_log_t
SU_LOG[];
74
#endif
75
76
#define VA_NONE "%s"
,""
77
78
#define SU_DEBUG_DEF(level) \
79
su_inline void su_debug_##level(char const *fmt, ...) \
80
__attribute__ ((__format__ (printf, 1, 2))); \
81
su_inline void su_debug_##level(char const *fmt, ...) \
82
{ va_list ap; va_start(ap, fmt); su_vllog(SU_LOG, level, fmt, ap); va_end(ap); }
83
84
//SU_DEBUG_DEF(0)
85
#define su_debug_0(_f, ...) su_llog(SU_LOG, 0, _f, __VA_ARGS__)
86
93
#define SU_DEBUG_0(x) (SU_LOG_LEVEL >= 0 ? (su_debug_0 x) : (void)0)
94
96
#define SU_LERROR(s) (su_llog(SU_LOG, 1, "%s: %s\n"
, (s), strerror(errno)))
98
#define SU_LSERROR(s) \
99
(su_llog(SU_LOG, 1, "%s: %s\n"
, (s), su_strerror(su_errno())))
100
#else
101
#define SU_DEBUG_0(x) ((void)0)
102
#define SU_LERROR(s) ((void)0)
103
#define SU_LSERROR(s) ((void)0)
104
#endif
105
106
#if SU_DEBUG_MAX >= 1
107
//SU_DEBUG_DEF(1)
108
#define su_debug_1(_f, ...) su_llog(SU_LOG, 1, _f, __VA_ARGS__)
109
110
118
#define SU_DEBUG_1(x) (SU_LOG_LEVEL >= 1 ? (su_debug_1 x) : (void)0)
119
#else
120
#define SU_DEBUG_1(x) (void)1
121
#endif
122
123
#if SU_DEBUG_MAX >= 2
124
//SU_DEBUG_DEF(2)
125
#define su_debug_2(_f, ...) su_llog(SU_LOG, 2, _f, __VA_ARGS__)
132
#define SU_DEBUG_2(x) (SU_LOG_LEVEL >= 2 ? (su_debug_2 x) : (void)0)
133
#else
134
#define SU_DEBUG_2(x) (void)2
135
#endif
136
137
#if SU_DEBUG_MAX >= 3
138
//SU_DEBUG_DEF(3)
139
#define su_debug_3(_f, ...) su_llog(SU_LOG, 3, _f, __VA_ARGS__)
146
#define SU_DEBUG_3(x) (SU_LOG_LEVEL >= 3 ? (su_debug_3 x) : (void)0)
147
#else
148
#define SU_DEBUG_3(x) (void)3
149
#endif
150
151
#if SU_DEBUG_MAX >= 4
152
//SU_DEBUG_DEF(4)
153
#define su_debug_4(_f, ...) su_llog(SU_LOG, 4, _f, __VA_ARGS__)
155
#define SU_DEBUG_4(x) (SU_LOG_LEVEL >= 4 ? (su_debug_4 x) : (void)0)
156
#else
157
#define SU_DEBUG_4(x) (void)4
158
#endif
159
160
#if SU_DEBUG_MAX >= 5
161
//SU_DEBUG_DEF(5)
162
#define su_debug_5(_f, ...) su_llog(SU_LOG, 5, _f, __VA_ARGS__)
170
#define SU_DEBUG_5(x) (SU_LOG_LEVEL >= 5 ? (su_debug_5 x) : (void)0)
171
#else
172
#define SU_DEBUG_5(x) (void)5
173
#endif
174
175
#if SU_DEBUG_MAX >= 6
176
//SU_DEBUG_DEF(6)
177
#define su_debug_6(_f, ...) su_llog(SU_LOG, 6, _f, __VA_ARGS__)
179
#define SU_DEBUG_6(x) (SU_LOG_LEVEL >= 6 ? (su_debug_6 x) : (void)0)
180
#else
181
#define SU_DEBUG_6(x) (void)6
182
#endif
183
184
#if SU_DEBUG_MAX >= 7
185
//SU_DEBUG_DEF(7)
186
#define su_debug_7(_f, ...) su_llog(SU_LOG, 7, _f, __VA_ARGS__)
193
#define SU_DEBUG_7(x) (SU_LOG_LEVEL >= 7 ? (su_debug_7 x) : (void)0)
194
#else
195
#define SU_DEBUG_7(x) (void)7
196
#endif
197
198
#if SU_DEBUG_MAX >= 8
199
//SU_DEBUG_DEF(8)
200
#define su_debug_8(_f, ...) su_llog(SU_LOG, 8, _f, __VA_ARGS__)
202
#define SU_DEBUG_8(x) (SU_LOG_LEVEL >= 8 ? (su_debug_8 x) : (void)0)
203
#else
204
#define SU_DEBUG_8(x) (void)8
205
#endif
206
207
#if SU_DEBUG_MAX >= 9
208
//SU_DEBUG_DEF(9)
209
#define su_debug_9(_f, ...) su_llog(SU_LOG, 9, _f, __VA_ARGS__)
217
#define SU_DEBUG_9(x) (SU_LOG_LEVEL >= 9 ? (su_debug_9 x) : (void)0)
218
#else
219
#define SU_DEBUG_9(x) (void)9
220
#endif
221
222
SOFIA_END_DECLS
223
224
#endif
/* SU_DEBUG_H */
su_log_s
Log object.
Definition:
su_log.h:68
SOFIAPUBVAR
#define SOFIAPUBVAR
SOFIAPUBVAR declares an exported variable.
Definition:
su_config.h:68
su_log.h
SU logging interface.
Sofia-SIP 1.13.17 - Copyright (C) 2006 Nokia Corporation. All rights reserved. Licensed under the terms of the GNU Lesser General Public License.