Don't call ERR_remove_state().
[oweals/tinc.git] / src / logger.h
1 #ifndef TINC_LOGGER_H
2 #define TINC_LOGGER_H
3
4 /*
5     logger.h -- header file for logger.c
6     Copyright (C) 2003-2016 Guus Sliepen <guus@tinc-vpn.org>
7
8     This program is free software; you can redistribute it and/or modify
9     it under the terms of the GNU General Public License as published by
10     the Free Software Foundation; either version 2 of the License, or
11     (at your option) any later version.
12
13     This program is distributed in the hope that it will be useful,
14     but WITHOUT ANY WARRANTY; without even the implied warranty of
15     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16     GNU General Public License for more details.
17
18     You should have received a copy of the GNU General Public License along
19     with this program; if not, write to the Free Software Foundation, Inc.,
20     51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
21 */
22
23 typedef enum debug_t {
24         DEBUG_NOTHING = 0,                      /* Quiet mode, only show starting/stopping of the daemon */
25         DEBUG_ALWAYS = 0,
26         DEBUG_CONNECTIONS = 1,          /* Show (dis)connects of other tinc daemons via TCP */
27         DEBUG_ERROR = 2,                        /* Show error messages received from other hosts */
28         DEBUG_STATUS = 2,                       /* Show status messages received from other hosts */
29         DEBUG_PROTOCOL = 3,                     /* Show the requests that are sent/received */
30         DEBUG_META = 4,                         /* Show contents of every request that is sent/received */
31         DEBUG_TRAFFIC = 5,                      /* Show network traffic information */
32         DEBUG_PACKET = 6,                       /* Show contents of each packet that is being sent/received */
33         DEBUG_SCARY_THINGS = 10         /* You have been warned */
34 } debug_t;
35
36 typedef enum logmode_t {
37         LOGMODE_NULL,
38         LOGMODE_STDERR,
39         LOGMODE_FILE,
40         LOGMODE_SYSLOG
41 } logmode_t;
42
43 #ifdef HAVE_MINGW
44 #define LOG_EMERG EVENTLOG_ERROR_TYPE
45 #define LOG_ALERT EVENTLOG_ERROR_TYPE
46 #define LOG_CRIT EVENTLOG_ERROR_TYPE
47 #define LOG_ERR EVENTLOG_ERROR_TYPE
48 #define LOG_WARNING EVENTLOG_WARNING_TYPE
49 #define LOG_NOTICE EVENTLOG_INFORMATION_TYPE
50 #define LOG_INFO EVENTLOG_INFORMATION_TYPE
51 #define LOG_DEBUG EVENTLOG_INFORMATION_TYPE
52 #else
53 #ifndef HAVE_SYSLOG_H
54 enum {
55         LOG_EMERG,
56         LOG_ALERT,
57         LOG_CRIT,
58         LOG_ERR,
59         LOG_WARNING,
60         LOG_NOTICE,
61         LOG_INFO,
62         LOG_DEBUG,
63 };
64 #endif
65 #endif
66
67 extern debug_t debug_level;
68 extern void openlogger(const char *, logmode_t);
69 extern void reopenlogger(void);
70 extern void logger(int, const char *, ...) __attribute__((__format__(printf, 2, 3)));
71 extern void closelogger(void);
72
73 #define ifdebug(l) if(debug_level >= DEBUG_##l)
74
75 #endif