dcbdcd466a6aa720120dcc3e35cccf8506b65e4d
1 /**
2 * collectd - src/quota_debug.h
3 * Copyright (C) 2005 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 **/
24 #if !COLLECTD_QUOTA_DEBUG_H
25 #define COLLECTD_QUOTA_DEBUG_H 1
27 #include "common.h"
29 #define QUOTA_PLUGIN_DEBUG 1
31 #if QUOTA_PLUGIN_DEBUG
32 #include <stdio.h>
33 extern FILE *QUOTA_DBG_FILE;
34 #define DBG(...) \
35 { \
36 if(QUOTA_DBG_FILE != NULL) { \
37 fprintf(QUOTA_DBG_FILE, "%s:%d:%s(): ", \
38 __FILE__, __LINE__, __func__); \
39 fprintf(QUOTA_DBG_FILE, __VA_ARGS__); \
40 fprintf(QUOTA_DBG_FILE, "\n"); \
41 fflush(QUOTA_DBG_FILE); \
42 } \
43 }
44 #define DBG_INIT(...) \
45 { \
46 QUOTA_DBG_FILE = fopen("collectd.log", "a"); \
47 if(QUOTA_DBG_FILE == NULL) { \
48 /* stderr is redirected to /dev/null, so you \
49 will not see anything */ \
50 fprintf(stderr, "Cannot open quota debug file.\n"); \
51 } else { \
52 DBG(__VA_ARGS__); \
53 } \
54 }
55 #else /* !QUOTA_PLUGIN_DEBUG */
56 #define DBG(...) /**/
57 #define DBG_INIT(...) /**/
58 #endif /* QUOTA_PLUGIN_DEBUG */
60 #endif /* !COLLECTD_QUOTA_DEBUG_H */