HL-HDF
hlhdf_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 HLHDF.
5
6HLHDF 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
11HLHDF 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 HLHDF. If not, see <http://www.gnu.org/licenses/>.
18------------------------------------------------------------------------*/
19
27#ifndef HLHDF_DEBUG_H
28#define HLHDF_DEBUG_H
29
30#include <H5Epublic.h>
31
47
51typedef struct {
53 void (*dbgfun)(char* filename, int lineno, HL_Debug lvl, const char* fmt,...);
55 void (*hdf5fun)(unsigned n, const H5E_error_t* rowmsg);
57
62
68void HL_printf(const char* fmt, ...);
69
74void HL_InitializeDebugger(void);
75
82
88void HL_setDebugFunction(void (*dbgfun)(char* filename, int lineno, HL_Debug lvl, const char* fmt, ...));
89
95void HL_setHdf5ErrorFunction(void (*hdf5fun)(unsigned n, const H5E_error_t* val));
96
102
108
115herr_t HL_hdf5_debug_function(hid_t estack, void *inv);
116
121#ifdef DEBUG_HLHDF
125#define HL_SPEWDEBUG0(msg) \
126hlhdfDbg.dbgfun(__FILE__,__LINE__,HLHDF_SPEWDEBUG,msg)
127
131#define HL_SPEWDEBUG1(msg,arg1) \
132hlhdfDbg.dbgfun(__FILE__,__LINE__,HLHDF_SPEWDEBUG,msg,arg1)
133
134#define HL_SPEWDEBUG2(msg,arg1,arg2) \
135hlhdfDbg.dbgfun(__FILE__,__LINE__,HLHDF_SPEWDEBUG,msg,arg1,arg2)
136
137#define HL_SPEWDEBUG3(msg,arg1,arg2,arg3) \
138hlhdfDbg.dbgfun(__FILE__,__LINE__,HLHDF_SPEWDEBUG,msg,arg1,arg2,arg3)
139
140#define HL_SPEWDEBUG4(msg,arg1,arg2,arg3,arg4) \
141hlhdfDbg.dbgfun(__FILE__,__LINE__,HLHDF_SPEWDEBUG,msg,arg1,arg2,arg3,arg4)
142
143#define HL_DEBUG0(msg) \
144hlhdfDbg.dbgfun(__FILE__,__LINE__,HLHDF_DEBUG,msg)
145
146#define HL_DEBUG1(msg,arg1) \
147hlhdfDbg.dbgfun(__FILE__,__LINE__,HLHDF_DEBUG,msg,arg1)
148
149#define HL_DEBUG2(msg,arg1,arg2) \
150hlhdfDbg.dbgfun(__FILE__,__LINE__,HLHDF_DEBUG,msg,arg1,arg2)
151
152#define HL_DEBUG3(msg,arg1,arg2,arg3) \
153hlhdfDbg.dbgfun(__FILE__,__LINE__,HLHDF_DEBUG,msg,arg1,arg2,arg3)
154
155#define HL_DEBUG4(msg,arg1,arg2,arg3,arg4) \
156hlhdfDbg.dbgfun(__FILE__,__LINE__,HLHDF_DEBUG,msg,arg1,arg2,arg3,arg4)
157
158#define HL_DEPRECATED0(msg) \
159hlhdfDbg.dbgfun(__FILE__,__LINE__,HLHDF_DEPRECATED,msg)
160
161#define HL_DEPRECATED1(msg,arg1) \
162hlhdfDbg.dbgfun(__FILE__,__LINE__,HLHDF_DEPRECATED,msg,arg1)
163
164#define HL_DEPRECATED2(msg,arg1,arg2) \
165hlhdfDbg.dbgfun(__FILE__,__LINE__,HLHDF_DEPRECATED,msg,arg1,arg2)
166
167#define HL_DEPRECATED3(msg,arg1,arg2,arg3) \
168hlhdfDbg.dbgfun(__FILE__,__LINE__,HLHDF_DEPRECATED,msg,arg1,arg2,arg3)
169
170#define HL_DEPRECATED4(msg,arg1,arg2,arg3,arg4) \
171hlhdfDbg.dbgfun(__FILE__,__LINE__,HLHDF_DEPRECATED,msg,arg1,arg2,arg3,arg4)
172
173#define HL_INFO0(msg) \
174hlhdfDbg.dbgfun(__FILE__,__LINE__,HLHDF_INFO,msg)
175
176#define HL_INFO1(msg,arg1) \
177hlhdfDbg.dbgfun(__FILE__,__LINE__,HLHDF_INFO,msg,arg1)
178
179#define HL_INFO2(msg,arg1,arg2) \
180hlhdfDbg.dbgfun(__FILE__,__LINE__,HLHDF_INFO,msg,arg1,arg2)
181
182#define HL_INFO3(msg,arg1,arg2,arg3) \
183hlhdfDbg.dbgfun(__FILE__,__LINE__,HLHDF_INFO,msg,arg1,arg2,arg3)
184
185#define HL_INFO4(msg,arg1,arg2,arg3,arg4) \
186hlhdfDbg.dbgfun(__FILE__,__LINE__,HLHDF_INFO,msg,arg1,arg2,arg3,arg4)
187
188#define HL_WARNING0(msg) \
189hlhdfDbg.dbgfun(__FILE__,__LINE__,HLHDF_WARNING,msg)
190
191#define HL_WARNING1(msg,arg1) \
192hlhdfDbg.dbgfun(__FILE__,__LINE__,HLHDF_WARNING,msg,arg1)
193
194#define HL_WARNING2(msg,arg1,arg2) \
195hlhdfDbg.dbgfun(__FILE__,__LINE__,HLHDF_WARNING,msg,arg1,arg2)
196
197#define HL_WARNING3(msg,arg1,arg2,arg3) \
198hlhdfDbg.dbgfun(__FILE__,__LINE__,HLHDF_WARNING,msg,arg1,arg2,arg3)
199
200#define HL_WARNING4(msg,arg1,arg2,arg3,arg4) \
201hlhdfDbg.dbgfun(__FILE__,__LINE__,HLHDF_WARNING,msg,arg1,arg2,arg3,arg4)
202
203#define HL_ERROR0(msg) \
204hlhdfDbg.dbgfun(__FILE__,__LINE__,HLHDF_ERROR,msg)
205
206#define HL_ERROR1(msg,arg1) \
207hlhdfDbg.dbgfun(__FILE__,__LINE__,HLHDF_ERROR,msg,arg1)
208
209#define HL_ERROR2(msg,arg1,arg2) \
210hlhdfDbg.dbgfun(__FILE__,__LINE__,HLHDF_ERROR,msg,arg1,arg2)
211
212#define HL_ERROR3(msg,arg1,arg2,arg3) \
213hlhdfDbg.dbgfun(__FILE__,__LINE__,HLHDF_ERROR,msg,arg1,arg2,arg3)
214
215#define HL_ERROR4(msg,arg1,arg2,arg3,arg4) \
216hlhdfDbg.dbgfun(__FILE__,__LINE__,HLHDF_ERROR,msg,arg1,arg2,arg3,arg4)
217
218#define HL_CRITICAL0(msg) \
219hlhdfDbg.dbgfun(__FILE__,__LINE__,HLHDF_CRITICAL,msg)
220
221#define HL_CRITICAL1(msg,arg1) \
222hlhdfDbg.dbgfun(__FILE__,__LINE__,HLHDF_CRITICAL,msg,arg1)
223
224#define HL_CRITICAL2(msg,arg1,arg2) \
225hlhdfDbg.dbgfun(__FILE__,__LINE__,HLHDF_CRITICAL,msg,arg1,arg2)
226
227#define HL_CRITICAL3(msg,arg1,arg2,arg3) \
228hlhdfDbg.dbgfun(__FILE__,__LINE__,HLHDF_CRITICAL,msg,arg1,arg2,arg3)
229
230#define HL_CRITICAL4(msg,arg1,arg2,arg3,arg4) \
231hlhdfDbg.dbgfun(__FILE__,__LINE__,HLHDF_CRITICAL,msg,arg1,arg2,arg3,arg4)
232
233#define HL_ASSERT(expr, msg) \
234if(!expr) { \
235hlhdfDbg.dbgfun(__FILE__, __LINE__, HLHDF_CRITICAL, msg); \
236abort(); \
237}
238
239
240#else
242#define HL_SPEWDEBUG0(msg)
243
245#define HL_SPEWDEBUG1(msg,arg1)
246
248#define HL_SPEWDEBUG2(msg,arg1,arg2)
249
251#define HL_SPEWDEBUG3(msg,arg1,arg2,arg3)
252
254#define HL_SPEWDEBUG4(msg,arg1,arg2,arg3,arg4)
255
257#define HL_DEBUG0(msg)
258
260#define HL_DEBUG1(msg,arg1)
261
263#define HL_DEBUG2(msg,arg1,arg2)
264
266#define HL_DEBUG3(msg,arg1,arg2,arg3)
267
269#define HL_DEBUG4(msg,arg1,arg2,arg3,arg4)
270
272#define HL_DEPRECATED0(msg)
273
275#define HL_DEPRECATED1(msg,arg1)
276
278#define HL_DEPRECATED2(msg,arg1,arg2)
279
281#define HL_DEPRECATED3(msg,arg1,arg2,arg3)
282
284#define HL_DEPRECATED4(msg,arg1,arg2,arg3,arg4)
285
287#define HL_INFO0(msg) \
288hlhdfDbg.dbgfun(__FILE__,__LINE__,HLHDF_INFO,msg)
289
291#define HL_INFO1(msg,arg1) \
292hlhdfDbg.dbgfun(__FILE__,__LINE__,HLHDF_INFO,msg,arg1)
293
295#define HL_INFO2(msg,arg1,arg2) \
296hlhdfDbg.dbgfun(__FILE__,__LINE__,HLHDF_INFO,msg,arg1,arg2)
297
299#define HL_INFO3(msg,arg1,arg2,arg3) \
300hlhdfDbg.dbgfun(__FILE__,__LINE__,HLHDF_INFO,msg,arg1,arg2,arg3)
301
303#define HL_INFO4(msg,arg1,arg2,arg3,arg4) \
304hlhdfDbg.dbgfun(__FILE__,__LINE__,HLHDF_INFO,msg,arg1,arg2,arg3,arg4)
305
307#define HL_WARNING0(msg) \
308hlhdfDbg.dbgfun(__FILE__,__LINE__,HLHDF_WARNING,msg)
309
311#define HL_WARNING1(msg,arg1) \
312hlhdfDbg.dbgfun(__FILE__,__LINE__,HLHDF_WARNING,msg,arg1)
313
315#define HL_WARNING2(msg,arg1,arg2) \
316hlhdfDbg.dbgfun(__FILE__,__LINE__,HLHDF_WARNING,msg,arg1,arg2)
317
319#define HL_WARNING3(msg,arg1,arg2,arg3) \
320hlhdfDbg.dbgfun(__FILE__,__LINE__,HLHDF_WARNING,msg,arg1,arg2,arg3)
321
323#define HL_WARNING4(msg,arg1,arg2,arg3,arg4) \
324hlhdfDbg.dbgfun(__FILE__,__LINE__,HLHDF_WARNING,msg,arg1,arg2,arg3,arg4)
325
327#define HL_ERROR0(msg) \
328hlhdfDbg.dbgfun(__FILE__,__LINE__,HLHDF_ERROR,msg)
329
331#define HL_ERROR1(msg,arg1) \
332hlhdfDbg.dbgfun(__FILE__,__LINE__,HLHDF_ERROR,msg,arg1)
333
335#define HL_ERROR2(msg,arg1,arg2) \
336hlhdfDbg.dbgfun(__FILE__,__LINE__,HLHDF_ERROR,msg,arg1,arg2)
337
339#define HL_ERROR3(msg,arg1,arg2,arg3) \
340hlhdfDbg.dbgfun(__FILE__,__LINE__,HLHDF_ERROR,msg,arg1,arg2,arg3)
341
343#define HL_ERROR4(msg,arg1,arg2,arg3,arg4) \
344hlhdfDbg.dbgfun(__FILE__,__LINE__,HLHDF_ERROR,msg,arg1,arg2,arg3,arg4)
345
347#define HL_CRITICAL0(msg) \
348hlhdfDbg.dbgfun(__FILE__,__LINE__,HLHDF_CRITICAL,msg)
349
351#define HL_CRITICAL1(msg,arg1) \
352hlhdfDbg.dbgfun(__FILE__,__LINE__,HLHDF_CRITICAL,msg,arg1)
353
355#define HL_CRITICAL2(msg,arg1,arg2) \
356hlhdfDbg.dbgfun(__FILE__,__LINE__,HLHDF_CRITICAL,msg,arg1,arg2)
357
359#define HL_CRITICAL3(msg,arg1,arg2,arg3) \
360hlhdfDbg.dbgfun(__FILE__,__LINE__,HLHDF_CRITICAL,msg,arg1,arg2,arg3)
361
363#define HL_CRITICAL4(msg,arg1,arg2,arg3,arg4) \
364hlhdfDbg.dbgfun(__FILE__,__LINE__,HLHDF_CRITICAL,msg,arg1,arg2,arg3,arg4)
365
366#ifdef NO_HLHDF_ABORT
367
368#define HL_ASSERT(expr, msg)
369#define HL_ABORT()
370
371#else
376#define HL_ASSERT(expr, msg) \
377if(!expr) { \
378hlhdfDbg.dbgfun(__FILE__, __LINE__, HLHDF_CRITICAL, msg); \
379abort(); \
380}
381
382#define HL_ABORT() abort()
383
384#endif
385
386#endif
389#endif
void HL_setHdf5ErrorFunction(void(*hdf5fun)(unsigned n, const H5E_error_t *val))
Sets the HDF5 error reporting function.
Definition hlhdf_debug.c:164
void HL_InitializeDebugger(void)
Initializes the debugger structure, must have been called before executing the code.
Definition hlhdf_debug.c:132
void HL_enableHdf5ErrorReporting(void)
Enables the HDF5 error reporting.
Definition hlhdf_debug.c:159
void HL_disableHdf5ErrorReporting(void)
Disables the HDF5 error reporting.
Definition hlhdf_debug.c:154
void HL_setDebugFunction(void(*dbgfun)(char *filename, int lineno, HL_Debug lvl, const char *fmt,...))
Sets the debug function where the debug printouts should be routed.
Definition hlhdf_debug.c:148
HL_Debug
Debug levels.
Definition hlhdf_debug.h:37
void HL_setDebugLevel(HL_Debug lvl)
Sets the debug level.
Definition hlhdf_debug.c:143
@ HLHDF_SILENT
Turns of debugging.
Definition hlhdf_debug.h:45
@ HLHDF_ERROR
Errors can be when memory not could be allocated or a file not could be created.
Definition hlhdf_debug.h:43
@ HLHDF_SPEWDEBUG
The most verbose printouts is turned on here.
Definition hlhdf_debug.h:38
@ HLHDF_DEBUG
Basic debug functions.
Definition hlhdf_debug.h:39
@ HLHDF_WARNING
Warnings.
Definition hlhdf_debug.h:42
@ HLHDF_DEPRECATED
Print outs deprecated warnings.
Definition hlhdf_debug.h:40
@ HLHDF_INFO
Informational messages.
Definition hlhdf_debug.h:41
@ HLHDF_CRITICAL
If this occurs, then something has gone very wrong or the code contains a bug, please report it to th...
Definition hlhdf_debug.h:44
void HL_printf(const char *fmt,...)
The printer function.
Definition hlhdf_debug.c:117
herr_t HL_hdf5_debug_function(hid_t estack, void *inv)
This is the debug function that is used to forward messages to the appropriate debugger function.
Definition hlhdf_debug.c:176
hlhdf_debug_struct hlhdfDbg
The main structure used for routing errors and debug printouts.
Definition hlhdf_debug.c:28
Debug structure.
Definition hlhdf_debug.h:51
int hdf5showerror
If hdf5 errors should be printed or not.
Definition hlhdf_debug.h:54
HL_Debug dbgLevel
Debug level.
Definition hlhdf_debug.h:52