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_ERROR5(msg,arg1,arg2,arg3,arg4,arg5) \
200Rave_getDebugFunction()(__FILE__,__LINE__,RAVE_ERROR,msg,arg1,arg2,arg3,arg4,arg5)
201
202#define RAVE_CRITICAL0(msg) \
203Rave_getDebugFunction()(__FILE__,__LINE__,RAVE_CRITICAL,msg)
204
205#define RAVE_CRITICAL1(msg,arg1) \
206Rave_getDebugFunction()(__FILE__,__LINE__,RAVE_CRITICAL,msg,arg1)
207
208#define RAVE_CRITICAL2(msg,arg1,arg2) \
209Rave_getDebugFunction()(__FILE__,__LINE__,RAVE_CRITICAL,msg,arg1,arg2)
210
211#define RAVE_CRITICAL3(msg,arg1,arg2,arg3) \
212Rave_getDebugFunction()(__FILE__,__LINE__,RAVE_CRITICAL,msg,arg1,arg2,arg3)
213
214#define RAVE_CRITICAL4(msg,arg1,arg2,arg3,arg4) \
215Rave_getDebugFunction()(__FILE__,__LINE__,RAVE_CRITICAL,msg,arg1,arg2,arg3,arg4)
216
217#define RAVE_ASSERT(expr, msg) \
218if(!expr) { \
219Rave_getDebugFunction()(__FILE__, __LINE__, RAVE_CRITICAL, msg); \
220abort(); \
221}
222
223#define RAVE_ABORT() abort()
224
225#else
227#define RAVE_SPEWDEBUG0(msg)
228
230#define RAVE_SPEWDEBUG1(msg,arg1)
231
233#define RAVE_SPEWDEBUG2(msg,arg1,arg2)
234
236#define RAVE_SPEWDEBUG3(msg,arg1,arg2,arg3)
237
239#define RAVE_SPEWDEBUG4(msg,arg1,arg2,arg3,arg4)
240
242#define RAVE_DEBUG0(msg)
243
245#define RAVE_DEBUG1(msg,arg1)
246
248#define RAVE_DEBUG2(msg,arg1,arg2)
249
251#define RAVE_DEBUG3(msg,arg1,arg2,arg3)
252
254#define RAVE_DEBUG4(msg,arg1,arg2,arg3,arg4)
255
257#define RAVE_DEBUG7(msg,arg1,arg2,arg3,arg4,arg5,arg6,arg7)
258
260#define RAVE_DEPRECATED0(msg)
261
263#define RAVE_DEPRECATED1(msg,arg1)
264
266#define RAVE_DEPRECATED2(msg,arg1,arg2)
267
269#define RAVE_DEPRECATED3(msg,arg1,arg2,arg3)
270
272#define RAVE_DEPRECATED4(msg,arg1,arg2,arg3,arg4)
273
275#define RAVE_INFO0(msg) \
276Rave_getDebugFunction()(__FILE__,__LINE__,RAVE_INFO,msg)
277
279#define RAVE_INFO1(msg,arg1) \
280Rave_getDebugFunction()(__FILE__,__LINE__,RAVE_INFO,msg,arg1)
281
283#define RAVE_INFO2(msg,arg1,arg2) \
284Rave_getDebugFunction()(__FILE__,__LINE__,RAVE_INFO,msg,arg1,arg2)
285
287#define RAVE_INFO3(msg,arg1,arg2,arg3) \
288Rave_getDebugFunction()(__FILE__,__LINE__,RAVE_INFO,msg,arg1,arg2,arg3)
289
291#define RAVE_INFO4(msg,arg1,arg2,arg3,arg4) \
292Rave_getDebugFunction()(__FILE__,__LINE__,RAVE_INFO,msg,arg1,arg2,arg3,arg4)
293
295#define RAVE_INFO7(msg,arg1,arg2,arg3,arg4,arg5,arg6,arg7) \
296Rave_getDebugFunction()(__FILE__,__LINE__,RAVE_INFO,msg,arg1,arg2,arg3,arg4,arg5,arg6,arg7)
297
299#define RAVE_WARNING0(msg) \
300Rave_getDebugFunction()(__FILE__,__LINE__,RAVE_WARNING,msg)
301
303#define RAVE_WARNING1(msg,arg1) \
304Rave_getDebugFunction()(__FILE__,__LINE__,RAVE_WARNING,msg,arg1)
305
307#define RAVE_WARNING2(msg,arg1,arg2) \
308Rave_getDebugFunction()(__FILE__,__LINE__,RAVE_WARNING,msg,arg1,arg2)
309
311#define RAVE_WARNING3(msg,arg1,arg2,arg3) \
312Rave_getDebugFunction()(__FILE__,__LINE__,RAVE_WARNING,msg,arg1,arg2,arg3)
313
315#define RAVE_WARNING4(msg,arg1,arg2,arg3,arg4) \
316Rave_getDebugFunction()(__FILE__,__LINE__,RAVE_WARNING,msg,arg1,arg2,arg3,arg4)
317
319#define RAVE_ERROR0(msg) \
320Rave_getDebugFunction()(__FILE__,__LINE__,RAVE_ERROR,msg)
321
323#define RAVE_ERROR1(msg,arg1) \
324Rave_getDebugFunction()(__FILE__,__LINE__,RAVE_ERROR,msg,arg1)
325
327#define RAVE_ERROR2(msg,arg1,arg2) \
328Rave_getDebugFunction()(__FILE__,__LINE__,RAVE_ERROR,msg,arg1,arg2)
329
331#define RAVE_ERROR3(msg,arg1,arg2,arg3) \
332Rave_getDebugFunction()(__FILE__,__LINE__,RAVE_ERROR,msg,arg1,arg2,arg3)
333
335#define RAVE_ERROR4(msg,arg1,arg2,arg3,arg4) \
336Rave_getDebugFunction()(__FILE__,__LINE__,RAVE_ERROR,msg,arg1,arg2,arg3,arg4)
337
338#define RAVE_ERROR5(msg,arg1,arg2,arg3,arg4,arg5) \
339Rave_getDebugFunction()(__FILE__,__LINE__,RAVE_ERROR,msg,arg1,arg2,arg3,arg4,arg5)
340
342#define RAVE_CRITICAL0(msg) \
343Rave_getDebugFunction()(__FILE__,__LINE__,RAVE_CRITICAL,msg)
344
346#define RAVE_CRITICAL1(msg,arg1) \
347Rave_getDebugFunction()(__FILE__,__LINE__,RAVE_CRITICAL,msg,arg1)
348
350#define RAVE_CRITICAL2(msg,arg1,arg2) \
351Rave_getDebugFunction()(__FILE__,__LINE__,RAVE_CRITICAL,msg,arg1,arg2)
352
354#define RAVE_CRITICAL3(msg,arg1,arg2,arg3) \
355Rave_getDebugFunction()(__FILE__,__LINE__,RAVE_CRITICAL,msg,arg1,arg2,arg3)
356
358#define RAVE_CRITICAL4(msg,arg1,arg2,arg3,arg4) \
359Rave_getDebugFunction()(__FILE__,__LINE__,RAVE_CRITICAL,msg,arg1,arg2,arg3,arg4)
360
361#ifdef NO_RAVE_ABORT
362
363#define RAVE_ASSERT(expr, msg)
364#define RAVE_ABORT()
365
366#else
367
368#define RAVE_ASSERT(expr, msg) \
369if(!expr) { \
370Rave_getDebugFunction()(__FILE__, __LINE__, RAVE_CRITICAL, msg); \
371abort(); \
372}
373#define RAVE_ABORT() abort()
374
375#endif
376
377#endif
379
380#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