solaris-fixes branch: Applied the swap-patch by Christophe Kalt.
[collectd.git] / src / utils_debug.h
1 /**
2  * collectd - src/utils_debug.h
3  * Copyright (C) 2005,2006  Niki W. Waibel
4  *
5  * This program is free software; you can redistribute it and/
6  * or modify it under the terms of the GNU General Public Li-
7  * cence as published by the Free Software Foundation; either
8  * version 2 of the Licence, or any later version.
9  *
10  * This program is distributed in the hope that it will be use-
11  * ful, but WITHOUT ANY WARRANTY; without even the implied war-
12  * ranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
13  * See the GNU General Public Licence for more details.
14  *
15  * You should have received a copy of the GNU General Public
16  * Licence along with this program; if not, write to the Free
17  * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139,
18  * USA.
19  *
20  * Author:
21  *   Niki W. Waibel <niki.waibel@gmx.net>
22 **/
23
24 /* BUG: at the moment you can use DBG_STARTFILE only ONCE in
25    your program. more then one logfile is not supported. */
26
27 #if !COLLECTD_UTILS_DEBUG_H
28 #define COLLECTD_UTILS_DEBUG_H 1
29
30 #if COLLECT_DEBUG
31
32 #define DBG(...) cu_debug(__FILE__, __LINE__, __func__, \
33         __VA_ARGS__)
34
35 #define DBG_STARTFILE(file, ...) cu_debug_startfile(__FILE__, __LINE__, \
36         __func__, file, __VA_ARGS__)
37 #define DBG_STOPFILE(...) cu_debug_stopfile(__FILE__, __LINE__, \
38         __func__, __VA_ARGS__)
39
40 #define DBG_RESETFILE(file) cu_debug_resetfile(__FILE__, __LINE__, __func__, \
41         filename)
42
43 void cu_debug(const char *file, int line, const char *func,
44         const char *format, ...);
45
46 int cu_debug_startfile(const char *file, int line, const char *func,
47         const char *filename, const char *format, ...);
48 int cu_debug_stopfile(const char *file, int line, const char *func,
49         const char *format, ...);
50
51 int cu_debug_resetfile(const char *file, int line, const char *func,
52         const char *filename);
53
54 #else /* !COLLECT_DEBUG */
55
56 #define DBG(...)                   /* DBG(...) */
57 #define DBG_STARTFILE(file, ...)   /* DBG_STARTFILE(file, ...) */
58 #define DBG_STOPFILE(...)          /* DBG_STOPFILE(...) */
59 #define DBG_RESETFILE(file)        /* DBG_RESETFILE(file) */
60
61 #endif /* COLLECT_DEBUG */
62
63 #endif /* !COLLECTD_UTILS_DEBUG_H */
64