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
53typedef void(*rave_dbgfun)(const char* filename, int lineno, Rave_Debug lvl, const char* fmt, ...);
54
60void Rave_printf(const char* fmt, ...);
61
67
74
79
86
91
96#ifdef DEBUG_RAVE
100#define RAVE_SPEWDEBUG0(msg) \
101Rave_getDebugFunction()(__FILE__,__LINE__,RAVE_SPEWDEBUG,msg)
102
106#define RAVE_SPEWDEBUG1(msg,arg1) \
107Rave_getDebugFunction()(__FILE__,__LINE__,RAVE_SPEWDEBUG,msg,arg1)
108
109#define RAVE_SPEWDEBUG2(msg,arg1,arg2) \
110Rave_getDebugFunction()(__FILE__,__LINE__,RAVE_SPEWDEBUG,msg,arg1,arg2)
111
112#define RAVE_SPEWDEBUG3(msg,arg1,arg2,arg3) \
113Rave_getDebugFunction()(__FILE__,__LINE__,RAVE_SPEWDEBUG,msg,arg1,arg2,arg3)
114
115#define RAVE_SPEWDEBUG4(msg,arg1,arg2,arg3,arg4) \
116Rave_getDebugFunction()(__FILE__,__LINE__,RAVE_SPEWDEBUG,msg,arg1,arg2,arg3,arg4)
117
118#define RAVE_DEBUG0(msg) \
119Rave_getDebugFunction()(__FILE__,__LINE__,RAVE_DEBUG,msg)
120
121#define RAVE_DEBUG1(msg,arg1) \
122Rave_getDebugFunction()(__FILE__,__LINE__,RAVE_DEBUG,msg,arg1)
123
124#define RAVE_DEBUG2(msg,arg1,arg2) \
125Rave_getDebugFunction()(__FILE__,__LINE__,RAVE_DEBUG,msg,arg1,arg2)
126
127#define RAVE_DEBUG3(msg,arg1,arg2,arg3) \
128Rave_getDebugFunction()(__FILE__,__LINE__,RAVE_DEBUG,msg,arg1,arg2,arg3)
129
130#define RAVE_DEBUG4(msg,arg1,arg2,arg3,arg4) \
131Rave_getDebugFunction()(__FILE__,__LINE__,RAVE_DEBUG,msg,arg1,arg2,arg3,arg4)
132
133#define RAVE_DEBUG7(msg,arg1,arg2,arg3,arg4,arg5,arg6,arg7) \
134Rave_getDebugFunction()(__FILE__,__LINE__,RAVE_DEBUG,msg,arg1,arg2,arg3,arg4,arg5,arg6,arg7)
135
136#define RAVE_DEPRECATED0(msg) \
137Rave_getDebugFunction()(__FILE__,__LINE__,RAVE_DEPRECATED,msg)
138
139#define RAVE_DEPRECATED1(msg,arg1) \
140Rave_getDebugFunction()(__FILE__,__LINE__,RAVE_DEPRECATED,msg,arg1)
141
142#define RAVE_DEPRECATED2(msg,arg1,arg2) \
143Rave_getDebugFunction()(__FILE__,__LINE__,RAVE_DEPRECATED,msg,arg1,arg2)
144
145#define RAVE_DEPRECATED3(msg,arg1,arg2,arg3) \
146Rave_getDebugFunction()(__FILE__,__LINE__,RAVE_DEPRECATED,msg,arg1,arg2,arg3)
147
148#define RAVE_DEPRECATED4(msg,arg1,arg2,arg3,arg4) \
149Rave_getDebugFunction()(__FILE__,__LINE__,RAVE_DEPRECATED,msg,arg1,arg2,arg3,arg4)
150
151#define RAVE_INFO0(msg) \
152Rave_getDebugFunction()(__FILE__,__LINE__,RAVE_INFO,msg)
153
154#define RAVE_INFO1(msg,arg1) \
155Rave_getDebugFunction()(__FILE__,__LINE__,RAVE_INFO,msg,arg1)
156
157#define RAVE_INFO2(msg,arg1,arg2) \
158Rave_getDebugFunction()(__FILE__,__LINE__,RAVE_INFO,msg,arg1,arg2)
159
160#define RAVE_INFO3(msg,arg1,arg2,arg3) \
161Rave_getDebugFunction()(__FILE__,__LINE__,RAVE_INFO,msg,arg1,arg2,arg3)
162
163#define RAVE_INFO4(msg,arg1,arg2,arg3,arg4) \
164Rave_getDebugFunction()(__FILE__,__LINE__,RAVE_INFO,msg,arg1,arg2,arg3,arg4)
165
166#define RAVE_INFO7(msg,arg1,arg2,arg3,arg4,arg5,arg6,arg7) \
167Rave_getDebugFunction()(__FILE__,__LINE__,RAVE_INFO,msg,arg1,arg2,arg3,arg4,arg5,arg6,arg7)
168
169#define RAVE_WARNING0(msg) \
170Rave_getDebugFunction()(__FILE__,__LINE__,RAVE_WARNING,msg)
171
172#define RAVE_WARNING1(msg,arg1) \
173Rave_getDebugFunction()(__FILE__,__LINE__,RAVE_WARNING,msg,arg1)
174
175#define RAVE_WARNING2(msg,arg1,arg2) \
176Rave_getDebugFunction()(__FILE__,__LINE__,RAVE_WARNING,msg,arg1,arg2)
177
178#define RAVE_WARNING3(msg,arg1,arg2,arg3) \
179Rave_getDebugFunction()(__FILE__,__LINE__,RAVE_WARNING,msg,arg1,arg2,arg3)
180
181#define RAVE_WARNING4(msg,arg1,arg2,arg3,arg4) \
182Rave_getDebugFunction()(__FILE__,__LINE__,RAVE_WARNING,msg,arg1,arg2,arg3,arg4)
183
184#define RAVE_ERROR0(msg) \
185Rave_getDebugFunction()(__FILE__,__LINE__,RAVE_ERROR,msg)
186
187#define RAVE_ERROR1(msg,arg1) \
188Rave_getDebugFunction()(__FILE__,__LINE__,RAVE_ERROR,msg,arg1)
189
190#define RAVE_ERROR2(msg,arg1,arg2) \
191Rave_getDebugFunction()(__FILE__,__LINE__,RAVE_ERROR,msg,arg1,arg2)
192
193#define RAVE_ERROR3(msg,arg1,arg2,arg3) \
194Rave_getDebugFunction()(__FILE__,__LINE__,RAVE_ERROR,msg,arg1,arg2,arg3)
195
196#define RAVE_ERROR4(msg,arg1,arg2,arg3,arg4) \
197Rave_getDebugFunction()(__FILE__,__LINE__,RAVE_ERROR,msg,arg1,arg2,arg3,arg4)
198
199#define RAVE_CRITICAL0(msg) \
200Rave_getDebugFunction()(__FILE__,__LINE__,RAVE_CRITICAL,msg)
201
202#define RAVE_CRITICAL1(msg,arg1) \
203Rave_getDebugFunction()(__FILE__,__LINE__,RAVE_CRITICAL,msg,arg1)
204
205#define RAVE_CRITICAL2(msg,arg1,arg2) \
206Rave_getDebugFunction()(__FILE__,__LINE__,RAVE_CRITICAL,msg,arg1,arg2)
207
208#define RAVE_CRITICAL3(msg,arg1,arg2,arg3) \
209Rave_getDebugFunction()(__FILE__,__LINE__,RAVE_CRITICAL,msg,arg1,arg2,arg3)
210
211#define RAVE_CRITICAL4(msg,arg1,arg2,arg3,arg4) \
212Rave_getDebugFunction()(__FILE__,__LINE__,RAVE_CRITICAL,msg,arg1,arg2,arg3,arg4)
213
214#define RAVE_ASSERT(expr, msg) \
215if(!expr) { \
216Rave_getDebugFunction()(__FILE__, __LINE__, RAVE_CRITICAL, msg); \
217abort(); \
218}
219
220#define RAVE_ABORT() abort()
221
222#else
224#define RAVE_SPEWDEBUG0(msg)
225
227#define RAVE_SPEWDEBUG1(msg,arg1)
228
230#define RAVE_SPEWDEBUG2(msg,arg1,arg2)
231
233#define RAVE_SPEWDEBUG3(msg,arg1,arg2,arg3)
234
236#define RAVE_SPEWDEBUG4(msg,arg1,arg2,arg3,arg4)
237
239#define RAVE_DEBUG0(msg)
240
242#define RAVE_DEBUG1(msg,arg1)
243
245#define RAVE_DEBUG2(msg,arg1,arg2)
246
248#define RAVE_DEBUG3(msg,arg1,arg2,arg3)
249
251#define RAVE_DEBUG4(msg,arg1,arg2,arg3,arg4)
252
254#define RAVE_DEBUG7(msg,arg1,arg2,arg3,arg4,arg5,arg6,arg7)
255
257#define RAVE_DEPRECATED0(msg)
258
260#define RAVE_DEPRECATED1(msg,arg1)
261
263#define RAVE_DEPRECATED2(msg,arg1,arg2)
264
266#define RAVE_DEPRECATED3(msg,arg1,arg2,arg3)
267
269#define RAVE_DEPRECATED4(msg,arg1,arg2,arg3,arg4)
270
272#define RAVE_INFO0(msg) \
273Rave_getDebugFunction()(__FILE__,__LINE__,RAVE_INFO,msg)
274
276#define RAVE_INFO1(msg,arg1) \
277Rave_getDebugFunction()(__FILE__,__LINE__,RAVE_INFO,msg,arg1)
278
280#define RAVE_INFO2(msg,arg1,arg2) \
281Rave_getDebugFunction()(__FILE__,__LINE__,RAVE_INFO,msg,arg1,arg2)
282
284#define RAVE_INFO3(msg,arg1,arg2,arg3) \
285Rave_getDebugFunction()(__FILE__,__LINE__,RAVE_INFO,msg,arg1,arg2,arg3)
286
288#define RAVE_INFO4(msg,arg1,arg2,arg3,arg4) \
289Rave_getDebugFunction()(__FILE__,__LINE__,RAVE_INFO,msg,arg1,arg2,arg3,arg4)
290
292#define RAVE_INFO7(msg,arg1,arg2,arg3,arg4,arg5,arg6,arg7) \
293Rave_getDebugFunction()(__FILE__,__LINE__,RAVE_INFO,msg,arg1,arg2,arg3,arg4,arg5,arg6,arg7)
294
296#define RAVE_WARNING0(msg) \
297Rave_getDebugFunction()(__FILE__,__LINE__,RAVE_WARNING,msg)
298
300#define RAVE_WARNING1(msg,arg1) \
301Rave_getDebugFunction()(__FILE__,__LINE__,RAVE_WARNING,msg,arg1)
302
304#define RAVE_WARNING2(msg,arg1,arg2) \
305Rave_getDebugFunction()(__FILE__,__LINE__,RAVE_WARNING,msg,arg1,arg2)
306
308#define RAVE_WARNING3(msg,arg1,arg2,arg3) \
309Rave_getDebugFunction()(__FILE__,__LINE__,RAVE_WARNING,msg,arg1,arg2,arg3)
310
312#define RAVE_WARNING4(msg,arg1,arg2,arg3,arg4) \
313Rave_getDebugFunction()(__FILE__,__LINE__,RAVE_WARNING,msg,arg1,arg2,arg3,arg4)
314
316#define RAVE_ERROR0(msg) \
317Rave_getDebugFunction()(__FILE__,__LINE__,RAVE_ERROR,msg)
318
320#define RAVE_ERROR1(msg,arg1) \
321Rave_getDebugFunction()(__FILE__,__LINE__,RAVE_ERROR,msg,arg1)
322
324#define RAVE_ERROR2(msg,arg1,arg2) \
325Rave_getDebugFunction()(__FILE__,__LINE__,RAVE_ERROR,msg,arg1,arg2)
326
328#define RAVE_ERROR3(msg,arg1,arg2,arg3) \
329Rave_getDebugFunction()(__FILE__,__LINE__,RAVE_ERROR,msg,arg1,arg2,arg3)
330
332#define RAVE_ERROR4(msg,arg1,arg2,arg3,arg4) \
333Rave_getDebugFunction()(__FILE__,__LINE__,RAVE_ERROR,msg,arg1,arg2,arg3,arg4)
334
336#define RAVE_CRITICAL0(msg) \
337Rave_getDebugFunction()(__FILE__,__LINE__,RAVE_CRITICAL,msg)
338
340#define RAVE_CRITICAL1(msg,arg1) \
341Rave_getDebugFunction()(__FILE__,__LINE__,RAVE_CRITICAL,msg,arg1)
342
344#define RAVE_CRITICAL2(msg,arg1,arg2) \
345Rave_getDebugFunction()(__FILE__,__LINE__,RAVE_CRITICAL,msg,arg1,arg2)
346
348#define RAVE_CRITICAL3(msg,arg1,arg2,arg3) \
349Rave_getDebugFunction()(__FILE__,__LINE__,RAVE_CRITICAL,msg,arg1,arg2,arg3)
350
352#define RAVE_CRITICAL4(msg,arg1,arg2,arg3,arg4) \
353Rave_getDebugFunction()(__FILE__,__LINE__,RAVE_CRITICAL,msg,arg1,arg2,arg3,arg4)
354
355#ifdef NO_RAVE_ABORT
356
357#define RAVE_ASSERT(expr, msg)
358#define RAVE_ABORT()
359
360#else
361
362#define RAVE_ASSERT(expr, msg) \
363if(!expr) { \
364Rave_getDebugFunction()(__FILE__, __LINE__, RAVE_CRITICAL, msg); \
365abort(); \
366}
367#define RAVE_ABORT() abort()
368
369#endif
370
371#endif
374#endif
rave_dbgfun Rave_getDebugFunction(void)
Definition rave_debug.c:144
Rave_Debug Rave_getDebugLevel(void)
Definition rave_debug.c:132
void Rave_setDebugLevel(Rave_Debug lvl)
Sets the debug level.
Definition rave_debug.c:124
void(* rave_dbgfun)(const char *filename, int lineno, Rave_Debug lvl, const char *fmt,...)
The debugger function.
Definition rave_debug.h:53
void Rave_initializeDebugger(void)
Initializes the debugger structure, must have been called before executing the code.
Definition rave_debug.c:115
void Rave_printf(const char *fmt,...)
The printer function.
Definition rave_debug.c:42
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
void Rave_setDebugFunction(rave_dbgfun dbgfun)
Sets the debug function where the debug printouts should be routed.
Definition rave_debug.c:138