fb8ec0b716add7adb21897fd4f26c4eaa3dc3a7f
[tinc] / src / logger.h
1 #ifndef __TINC_LOGGER_H__
2 #define __TINC_LOGGER_H__
3
4 typedef enum debug_t {
5         DEBUG_NOTHING = 0,                      /* Quiet mode, only show starting/stopping of the daemon */
6         DEBUG_ALWAYS = 0,
7         DEBUG_CONNECTIONS = 1,          /* Show (dis)connects of other tinc daemons via TCP */
8         DEBUG_ERROR = 2,                        /* Show error messages received from other hosts */
9         DEBUG_STATUS = 2,                       /* Show status messages received from other hosts */
10         DEBUG_PROTOCOL = 3,                     /* Show the requests that are sent/received */
11         DEBUG_META = 4,                         /* Show contents of every request that is sent/received */
12         DEBUG_TRAFFIC = 5,                      /* Show network traffic information */
13         DEBUG_PACKET = 6,                       /* Show contents of each packet that is being sent/received */
14         DEBUG_SCARY_THINGS = 10         /* You have been warned */
15 } debug_t;
16
17 typedef enum logmode_t {
18         LOGMODE_NULL,
19         LOGMODE_STDERR,
20         LOGMODE_FILE,
21         LOGMODE_SYSLOG
22 } logmode_t;
23
24 #ifndef HAVE_SYSLOG_H
25 enum {
26         LOG_EMERG,
27         LOG_ALERT,
28         LOG_CRIT,
29         LOG_ERR,
30         LOG_WARNING,
31         LOG_NOTICE,
32         LOG_INFO,
33         LOG_DEBUG,
34 };
35 #endif
36
37 extern debug_t debug_level;
38 extern void openlogger(const char *, logmode_t);
39 extern void logger(int, const char *, ...) __attribute__ ((__format__(printf, 2, 3)));
40 extern void closelogger(void);
41
42 #define ifdebug(l) if(debug_level >= DEBUG_##l)
43
44 #endif /* __TINC_LOGGER_H__ */