ba70f23348de03804483b0b4a1edbe48e7af2a81
[monky] / src / logging.h
1 /* Conky, a system monitor, based on torsmo
2  *
3  * Any original torsmo code is licensed under the BSD license
4  *
5  * All code written since the fork of torsmo is licensed under the GPL
6  *
7  * Please see COPYING for details
8  *
9  * Copyright (c) 2004, Hannu Saransaari and Lauri Hakkarainen
10  * Copyright (c) 2005-2009 Brenden Matthews, Philip Kovacs, et. al.
11  *      (see AUTHORS)
12  * All rights reserved.
13  *
14  * This program is free software: you can redistribute it and/or modify
15  * it under the terms of the GNU General Public License as published by
16  * the Free Software Foundation, either version 3 of the License, or
17  * (at your option) any later version.
18  *
19  * This program is distributed in the hope that it will be useful,
20  * but WITHOUT ANY WARRANTY; without even the implied warranty of
21  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
22  * GNU General Public License for more details.
23  * You should have received a copy of the GNU General Public License
24  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
25  *
26  */
27
28 void clean_up(void *memtofree1, void* memtofree2);
29
30 #ifndef _LOGGING_H
31 #define _LOGGING_H
32
33 #define ERR(...) { \
34         fprintf(stderr, PACKAGE_NAME": "); \
35         fprintf(stderr, __VA_ARGS__); \
36         fprintf(stderr, "\n"); \
37 }
38
39 /* critical error */
40 #define CRIT_ERR(memtofree1, memtofree2, ...) \
41         { ERR(__VA_ARGS__); clean_up(memtofree1, memtofree2); exit(EXIT_FAILURE); }
42
43 /* debugging output */
44 extern int global_debug_level;
45 #define __DBGP(level, ...) \
46         if (global_debug_level > level) { \
47                 fprintf(stderr, "DEBUG(%d) [" __FILE__ ":%d]: ", level, __LINE__); \
48                 fprintf(stderr, __VA_ARGS__); \
49                 fprintf(stderr, "\n"); \
50         }
51 #define DBGP(...) __DBGP(0, __VA_ARGS__)
52 #define DBGP2(...) __DBGP(1, __VA_ARGS__)
53
54 #endif /* _LOGGING_H */