smf_trace.h
Go to the documentation of this file.
1 /* spmfilter - mail filtering framework
2  * Copyright (C) 2009-2012 Axel Steiner and SpaceNet AG
3  *
4  * This program is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Lesser General Public
6  * License as published by the Free Software Foundation; either
7  * version 3 of the License, or (at your option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12  * Lesser General Public License for more details.
13  *
14  * You should have received a copy of the GNU Lesser General Public
15  * License along with this program. If not, see <http://www.gnu.org/licenses/>.
16  */
17 
23 #ifndef _SMF_TRACE_H
24 #define _SMF_TRACE_H
25 
30 typedef enum {
31  TRACE_EMERG = 1,
32  TRACE_ALERT = 2,
33  TRACE_CRIT = 4,
34  TRACE_ERR = 8,
35  TRACE_WARNING = 16,
36  TRACE_NOTICE = 32,
37  TRACE_INFO = 64,
38  TRACE_DEBUG = 128,
39  TRACE_LOOKUP = 256 // Logs at Debug Level
40 } SMFTrace_T;
41 
46 typedef enum {
47  TRACE_DEST_SYSLOG,
48  TRACE_DEST_STDERR
50 
58 #define TRACE(level, fmt...) trace(level, THIS_MODULE, __func__, __LINE__, NULL, fmt)
59 
64 #define STRACE(level, sid, fmt...) trace(level, THIS_MODULE, __func__, __LINE__, sid, fmt)
65 
66 #ifndef DOXYGEN_SHOULD_SKIP_THIS
67 void trace(SMFTrace_T level, const char * module, const char * function, int line, const char *sid, const char *formatstring, ...);
68 #endif /* DOXYGEN_SHOULD_SKIP_THIS */
69 
75 void configure_debug(int debug);
76 
82 void configure_trace_destination(SMFTraceDest_T dest);
83 
88 #define TRDEBUG(fmt, ...) TRACE(TRACE_DEBUG, fmt, ##__VA_ARGS__)
89 
94 #define TRINFO(fmt, ...) TRACE(TRACE_INFO, fmt, ##__VA_ARGS__)
95 
100 #define TRNOTICE(fmt, ...) TRACE(TRACE_NOTICE, fmt, ##__VA_ARGS__)
101 
106 #define TRWARN(fmt, ...) TRACE(TRACE_WARNING, fmt, ##__VA_ARGS__)
107 
112 #define TRERR(fmt, ...) TRACE(TRACE_ERR, fmt, ##__VA_ARGS__)
113 
118 #define TRCRIT(fmt, ...) TRACE(TRACE_CRIT, fmt, ##__VA_ARGS__)
119 
124 #define TRALERT(fmt, ...) TRACE(TRACE_ALERT, fmt, ##__VA_ARGS__)
125 
130 #define TREMERG(fmt, ...) TRACE(TRACE_EMERG, fmt, ##__VA_ARGS__)
131 
132 #endif /* _SMF_TRACE_H */
133