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