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