RAVE
rave_debug.h
Go to the documentation of this file.
1/* --------------------------------------------------------------------
2Copyright (C) 2009 Swedish Meteorological and Hydrological Institute, SMHI,
3
4This file is part of RAVE.
5
6RAVE is free software: you can redistribute it and/or modify
7it under the terms of the GNU Lesser General Public License as published by
8the Free Software Foundation, either version 3 of the License, or
9(at your option) any later version.
10
11RAVE is distributed in the hope that it will be useful,
12but WITHOUT ANY WARRANTY; without even the implied warranty of
13MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14GNU Lesser General Public License for more details.
15
16You should have received a copy of the GNU Lesser General Public License
17along with RAVE. If not, see <http://www.gnu.org/licenses/>.
18------------------------------------------------------------------------*/
19
26#ifndef RAVE_DEBUG_H
27#define RAVE_DEBUG_H
28
44
54
63typedef void(*rave_dbgfun)(const char* filename, int lineno, Rave_Debug lvl, const char* fmt, ...);
64
70void Rave_printf(const char* fmt, ...);
71
76void Rave_initializeDebugger(void);
77
83void Rave_setDebugLevel(Rave_Debug lvl);
84
88Rave_Debug Rave_getDebugLevel(void);
89
96void Rave_setLogLevel(const char* lvl);
97
101const char* Rave_getLogLevel(void);
102
108void Rave_setDebugFunction(rave_dbgfun dbgfun);
109
113rave_dbgfun Rave_getDebugFunction(void);
114
119void Rave_setLogOutputStderr(void);
120
129int Rave_setLogOutputFile(const char* filename);
130
138void Rave_setLogOutputSyslog(const char* logid, const char* facility);
139
143Rave_LogOutput Rave_getLogOutput(void);
144
149#ifdef DEBUG_RAVE
153#define RAVE_SPEWDEBUG0(msg) \
154Rave_getDebugFunction()(__FILE__,__LINE__,RAVE_SPEWDEBUG,msg)
155
159#define RAVE_SPEWDEBUG1(msg,arg1) \
160Rave_getDebugFunction()(__FILE__,__LINE__,RAVE_SPEWDEBUG,msg,arg1)
161
162#define RAVE_SPEWDEBUG2(msg,arg1,arg2) \
163Rave_getDebugFunction()(__FILE__,__LINE__,RAVE_SPEWDEBUG,msg,arg1,arg2)
164
165#define RAVE_SPEWDEBUG3(msg,arg1,arg2,arg3) \
166Rave_getDebugFunction()(__FILE__,__LINE__,RAVE_SPEWDEBUG,msg,arg1,arg2,arg3)
167
168#define RAVE_SPEWDEBUG4(msg,arg1,arg2,arg3,arg4) \
169Rave_getDebugFunction()(__FILE__,__LINE__,RAVE_SPEWDEBUG,msg,arg1,arg2,arg3,arg4)
170
171#define RAVE_DEBUG0(msg) \
172Rave_getDebugFunction()(__FILE__,__LINE__,RAVE_DEBUG,msg)
173
174#define RAVE_DEBUG1(msg,arg1) \
175Rave_getDebugFunction()(__FILE__,__LINE__,RAVE_DEBUG,msg,arg1)
176
177#define RAVE_DEBUG2(msg,arg1,arg2) \
178Rave_getDebugFunction()(__FILE__,__LINE__,RAVE_DEBUG,msg,arg1,arg2)
179
180#define RAVE_DEBUG3(msg,arg1,arg2,arg3) \
181Rave_getDebugFunction()(__FILE__,__LINE__,RAVE_DEBUG,msg,arg1,arg2,arg3)
182
183#define RAVE_DEBUG4(msg,arg1,arg2,arg3,arg4) \
184Rave_getDebugFunction()(__FILE__,__LINE__,RAVE_DEBUG,msg,arg1,arg2,arg3,arg4)
185
186#define RAVE_DEBUG7(msg,arg1,arg2,arg3,arg4,arg5,arg6,arg7) \
187Rave_getDebugFunction()(__FILE__,__LINE__,RAVE_DEBUG,msg,arg1,arg2,arg3,arg4,arg5,arg6,arg7)
188
189#define RAVE_DEPRECATED0(msg) \
190Rave_getDebugFunction()(__FILE__,__LINE__,RAVE_DEPRECATED,msg)
191
192#define RAVE_DEPRECATED1(msg,arg1) \
193Rave_getDebugFunction()(__FILE__,__LINE__,RAVE_DEPRECATED,msg,arg1)
194
195#define RAVE_DEPRECATED2(msg,arg1,arg2) \
196Rave_getDebugFunction()(__FILE__,__LINE__,RAVE_DEPRECATED,msg,arg1,arg2)
197
198#define RAVE_DEPRECATED3(msg,arg1,arg2,arg3) \
199Rave_getDebugFunction()(__FILE__,__LINE__,RAVE_DEPRECATED,msg,arg1,arg2,arg3)
200
201#define RAVE_DEPRECATED4(msg,arg1,arg2,arg3,arg4) \
202Rave_getDebugFunction()(__FILE__,__LINE__,RAVE_DEPRECATED,msg,arg1,arg2,arg3,arg4)
203
204#define RAVE_INFO0(msg) \
205Rave_getDebugFunction()(__FILE__,__LINE__,RAVE_INFO,msg)
206
207#define RAVE_INFO1(msg,arg1) \
208Rave_getDebugFunction()(__FILE__,__LINE__,RAVE_INFO,msg,arg1)
209
210#define RAVE_INFO2(msg,arg1,arg2) \
211Rave_getDebugFunction()(__FILE__,__LINE__,RAVE_INFO,msg,arg1,arg2)
212
213#define RAVE_INFO3(msg,arg1,arg2,arg3) \
214Rave_getDebugFunction()(__FILE__,__LINE__,RAVE_INFO,msg,arg1,arg2,arg3)
215
216#define RAVE_INFO4(msg,arg1,arg2,arg3,arg4) \
217Rave_getDebugFunction()(__FILE__,__LINE__,RAVE_INFO,msg,arg1,arg2,arg3,arg4)
218
219#define RAVE_INFO7(msg,arg1,arg2,arg3,arg4,arg5,arg6,arg7) \
220Rave_getDebugFunction()(__FILE__,__LINE__,RAVE_INFO,msg,arg1,arg2,arg3,arg4,arg5,arg6,arg7)
221
222#define RAVE_WARNING0(msg) \
223Rave_getDebugFunction()(__FILE__,__LINE__,RAVE_WARNING,msg)
224
225#define RAVE_WARNING1(msg,arg1) \
226Rave_getDebugFunction()(__FILE__,__LINE__,RAVE_WARNING,msg,arg1)
227
228#define RAVE_WARNING2(msg,arg1,arg2) \
229Rave_getDebugFunction()(__FILE__,__LINE__,RAVE_WARNING,msg,arg1,arg2)
230
231#define RAVE_WARNING3(msg,arg1,arg2,arg3) \
232Rave_getDebugFunction()(__FILE__,__LINE__,RAVE_WARNING,msg,arg1,arg2,arg3)
233
234#define RAVE_WARNING4(msg,arg1,arg2,arg3,arg4) \
235Rave_getDebugFunction()(__FILE__,__LINE__,RAVE_WARNING,msg,arg1,arg2,arg3,arg4)
236
237#define RAVE_ERROR0(msg) \
238Rave_getDebugFunction()(__FILE__,__LINE__,RAVE_ERROR,msg)
239
240#define RAVE_ERROR1(msg,arg1) \
241Rave_getDebugFunction()(__FILE__,__LINE__,RAVE_ERROR,msg,arg1)
242
243#define RAVE_ERROR2(msg,arg1,arg2) \
244Rave_getDebugFunction()(__FILE__,__LINE__,RAVE_ERROR,msg,arg1,arg2)
245
246#define RAVE_ERROR3(msg,arg1,arg2,arg3) \
247Rave_getDebugFunction()(__FILE__,__LINE__,RAVE_ERROR,msg,arg1,arg2,arg3)
248
249#define RAVE_ERROR4(msg,arg1,arg2,arg3,arg4) \
250Rave_getDebugFunction()(__FILE__,__LINE__,RAVE_ERROR,msg,arg1,arg2,arg3,arg4)
251
252#define RAVE_ERROR5(msg,arg1,arg2,arg3,arg4,arg5) \
253Rave_getDebugFunction()(__FILE__,__LINE__,RAVE_ERROR,msg,arg1,arg2,arg3,arg4,arg5)
254
255#define RAVE_CRITICAL0(msg) \
256Rave_getDebugFunction()(__FILE__,__LINE__,RAVE_CRITICAL,msg)
257
258#define RAVE_CRITICAL1(msg,arg1) \
259Rave_getDebugFunction()(__FILE__,__LINE__,RAVE_CRITICAL,msg,arg1)
260
261#define RAVE_CRITICAL2(msg,arg1,arg2) \
262Rave_getDebugFunction()(__FILE__,__LINE__,RAVE_CRITICAL,msg,arg1,arg2)
263
264#define RAVE_CRITICAL3(msg,arg1,arg2,arg3) \
265Rave_getDebugFunction()(__FILE__,__LINE__,RAVE_CRITICAL,msg,arg1,arg2,arg3)
266
267#define RAVE_CRITICAL4(msg,arg1,arg2,arg3,arg4) \
268Rave_getDebugFunction()(__FILE__,__LINE__,RAVE_CRITICAL,msg,arg1,arg2,arg3,arg4)
269
270#define RAVE_ASSERT(expr, msg) \
271if(!expr) { \
272Rave_getDebugFunction()(__FILE__, __LINE__, RAVE_CRITICAL, msg); \
273abort(); \
274}
275
276#define RAVE_ABORT() abort()
277
278#else
280#define RAVE_SPEWDEBUG0(msg)
281
283#define RAVE_SPEWDEBUG1(msg,arg1)
284
286#define RAVE_SPEWDEBUG2(msg,arg1,arg2)
287
289#define RAVE_SPEWDEBUG3(msg,arg1,arg2,arg3)
290
292#define RAVE_SPEWDEBUG4(msg,arg1,arg2,arg3,arg4)
293
295#define RAVE_DEBUG0(msg)
296
298#define RAVE_DEBUG1(msg,arg1)
299
301#define RAVE_DEBUG2(msg,arg1,arg2)
302
304#define RAVE_DEBUG3(msg,arg1,arg2,arg3)
305
307#define RAVE_DEBUG4(msg,arg1,arg2,arg3,arg4)
308
310#define RAVE_DEBUG7(msg,arg1,arg2,arg3,arg4,arg5,arg6,arg7)
311
313#define RAVE_DEPRECATED0(msg)
314
316#define RAVE_DEPRECATED1(msg,arg1)
317
319#define RAVE_DEPRECATED2(msg,arg1,arg2)
320
322#define RAVE_DEPRECATED3(msg,arg1,arg2,arg3)
323
325#define RAVE_DEPRECATED4(msg,arg1,arg2,arg3,arg4)
326
328#define RAVE_INFO0(msg) \
329Rave_getDebugFunction()(__FILE__,__LINE__,RAVE_INFO,msg)
330
332#define RAVE_INFO1(msg,arg1) \
333Rave_getDebugFunction()(__FILE__,__LINE__,RAVE_INFO,msg,arg1)
334
336#define RAVE_INFO2(msg,arg1,arg2) \
337Rave_getDebugFunction()(__FILE__,__LINE__,RAVE_INFO,msg,arg1,arg2)
338
340#define RAVE_INFO3(msg,arg1,arg2,arg3) \
341Rave_getDebugFunction()(__FILE__,__LINE__,RAVE_INFO,msg,arg1,arg2,arg3)
342
344#define RAVE_INFO4(msg,arg1,arg2,arg3,arg4) \
345Rave_getDebugFunction()(__FILE__,__LINE__,RAVE_INFO,msg,arg1,arg2,arg3,arg4)
346
348#define RAVE_INFO7(msg,arg1,arg2,arg3,arg4,arg5,arg6,arg7) \
349Rave_getDebugFunction()(__FILE__,__LINE__,RAVE_INFO,msg,arg1,arg2,arg3,arg4,arg5,arg6,arg7)
350
352#define RAVE_WARNING0(msg) \
353Rave_getDebugFunction()(__FILE__,__LINE__,RAVE_WARNING,msg)
354
356#define RAVE_WARNING1(msg,arg1) \
357Rave_getDebugFunction()(__FILE__,__LINE__,RAVE_WARNING,msg,arg1)
358
360#define RAVE_WARNING2(msg,arg1,arg2) \
361Rave_getDebugFunction()(__FILE__,__LINE__,RAVE_WARNING,msg,arg1,arg2)
362
364#define RAVE_WARNING3(msg,arg1,arg2,arg3) \
365Rave_getDebugFunction()(__FILE__,__LINE__,RAVE_WARNING,msg,arg1,arg2,arg3)
366
368#define RAVE_WARNING4(msg,arg1,arg2,arg3,arg4) \
369Rave_getDebugFunction()(__FILE__,__LINE__,RAVE_WARNING,msg,arg1,arg2,arg3,arg4)
370
372#define RAVE_ERROR0(msg) \
373Rave_getDebugFunction()(__FILE__,__LINE__,RAVE_ERROR,msg)
374
376#define RAVE_ERROR1(msg,arg1) \
377Rave_getDebugFunction()(__FILE__,__LINE__,RAVE_ERROR,msg,arg1)
378
380#define RAVE_ERROR2(msg,arg1,arg2) \
381Rave_getDebugFunction()(__FILE__,__LINE__,RAVE_ERROR,msg,arg1,arg2)
382
384#define RAVE_ERROR3(msg,arg1,arg2,arg3) \
385Rave_getDebugFunction()(__FILE__,__LINE__,RAVE_ERROR,msg,arg1,arg2,arg3)
386
388#define RAVE_ERROR4(msg,arg1,arg2,arg3,arg4) \
389Rave_getDebugFunction()(__FILE__,__LINE__,RAVE_ERROR,msg,arg1,arg2,arg3,arg4)
390
391#define RAVE_ERROR5(msg,arg1,arg2,arg3,arg4,arg5) \
392Rave_getDebugFunction()(__FILE__,__LINE__,RAVE_ERROR,msg,arg1,arg2,arg3,arg4,arg5)
393
395#define RAVE_CRITICAL0(msg) \
396Rave_getDebugFunction()(__FILE__,__LINE__,RAVE_CRITICAL,msg)
397
399#define RAVE_CRITICAL1(msg,arg1) \
400Rave_getDebugFunction()(__FILE__,__LINE__,RAVE_CRITICAL,msg,arg1)
401
403#define RAVE_CRITICAL2(msg,arg1,arg2) \
404Rave_getDebugFunction()(__FILE__,__LINE__,RAVE_CRITICAL,msg,arg1,arg2)
405
407#define RAVE_CRITICAL3(msg,arg1,arg2,arg3) \
408Rave_getDebugFunction()(__FILE__,__LINE__,RAVE_CRITICAL,msg,arg1,arg2,arg3)
409
411#define RAVE_CRITICAL4(msg,arg1,arg2,arg3,arg4) \
412Rave_getDebugFunction()(__FILE__,__LINE__,RAVE_CRITICAL,msg,arg1,arg2,arg3,arg4)
413
414#ifdef NO_RAVE_ABORT
415
416#define RAVE_ASSERT(expr, msg)
417#define RAVE_ABORT()
418
419#else
420
421#define RAVE_ASSERT(expr, msg) \
422if(!expr) { \
423Rave_getDebugFunction()(__FILE__, __LINE__, RAVE_CRITICAL, msg); \
424abort(); \
425}
426#define RAVE_ABORT() abort()
427
428#endif
429
430#endif
432
433#endif
Rave_LogOutput
Where the default debug function should route its printouts.
Definition rave_debug.h:49
@ RAVE_LOG_OUTPUT_STDERR
Printouts go to stderr.
Definition rave_debug.h:50
@ RAVE_LOG_OUTPUT_FILE
Printouts go to a log file, see Rave_setLogOutputFile.
Definition rave_debug.h:51
@ RAVE_LOG_OUTPUT_SYSLOG
Printouts go to syslog, see Rave_setLogOutputSyslog.
Definition rave_debug.h:52
void(*) rave_dbgfun(const char *filename, int lineno, Rave_Debug lvl, const char *fmt,...)
The debugger function.
Definition rave_debug.h:63
Rave_Debug
Debug levels.
Definition rave_debug.h:34
@ RAVE_CRITICAL
If this occurs, then something has gone very wrong or the code contains a bug, please report it to th...
Definition rave_debug.h:41
@ RAVE_ERROR
Errors can be when memory not could be allocated or a file not could be created.
Definition rave_debug.h:40
@ RAVE_INFO
Informational messages.
Definition rave_debug.h:38
@ RAVE_WARNING
Warnings.
Definition rave_debug.h:39
@ RAVE_SILENT
Turns of debugging.
Definition rave_debug.h:42
@ RAVE_DEBUG
Basic debug functions.
Definition rave_debug.h:36
@ RAVE_DEPRECATED
Print outs deprecated warnings.
Definition rave_debug.h:37
@ RAVE_SPEWDEBUG
The most verbose printouts is turned on here.
Definition rave_debug.h:35
int Rave_setLogOutputFile(const char *filename)
Sets the default debug function's printouts to use a log file.
Definition rave_debug.c:313
void Rave_setLogOutputSyslog(const char *logid, const char *facility)
Sets the default debug function's printouts to use syslog.
Definition rave_debug.c:332