Update documents.
[oweals/tinc.git] / logger / log.h
1 /*
2     log.h -- logging
3
4     Copyright (C) 2003-2004 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
17     along with this program; if not, write to the Free Software
18     Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19
20     $Id$
21 */
22
23 #ifndef __LOGGER_H__
24 #define __LOGGER_H__
25
26 typedef enum debug_t {
27         DEBUG_NOTHING = 0,                      /* Quiet mode, only show starting/stopping of the daemon */
28         DEBUG_ALWAYS = 0,
29         DEBUG_CONNECTIONS = 1,          /* Show (dis)connects of other tinc daemons via TCP */
30         DEBUG_ERROR = 2,                        /* Show error messages received from other hosts */
31         DEBUG_STATUS = 2,                       /* Show status messages received from other hosts */
32         DEBUG_PROTOCOL = 3,                     /* Show the requests that are sent/received */
33         DEBUG_META = 4,                         /* Show contents of every request that is sent/received */
34         DEBUG_TRAFFIC = 5,                      /* Show network traffic information */
35         DEBUG_PACKET = 6,                       /* Show contents of each packet that is being sent/received */
36         DEBUG_SCARY_THINGS = 10         /* You have been warned */
37 } debug_t;
38
39 typedef enum logmode_t {
40         LOGMODE_NULL,
41         LOGMODE_STDERR,
42         LOGMODE_FILE,
43         LOGMODE_SYSLOG
44 } logmode_t;
45
46 #ifdef HAVE_MINGW
47 #define LOG_EMERG EVENTLOG_ERROR_TYPE
48 #define LOG_ALERT EVENTLOG_ERROR_TYPE
49 #define LOG_CRIT EVENTLOG_ERROR_TYPE
50 #define LOG_ERR EVENTLOG_ERROR_TYPE
51 #define LOG_WARNING EVENTLOG_WARNING_TYPE
52 #define LOG_NOTICE EVENTLOG_INFORMATION_TYPE
53 #define LOG_INFO EVENTLOG_INFORMATION_TYPE
54 #define LOG_DEBUG EVENTLOG_INFORMATION_TYPE
55 #else
56 #ifndef HAVE_SYSLOG_H
57 enum {
58         LOG_EMERG,
59         LOG_ALERT,
60         LOG_CRIT,
61         LOG_ERR,
62         LOG_WARNING,
63         LOG_NOTICE,
64         LOG_INFO,
65         LOG_DEBUG,
66 };
67 #endif
68 #endif
69
70 extern debug_t debug_level;
71 extern void openlogger(const char *, logmode_t);
72 extern void logger(int, const char *, ...) __attribute__ ((__format__(printf, 2, 3)));
73 extern void closelogger(void);
74
75 #define ifdebug(l) if(debug_level >= DEBUG_##l)
76
77 #endif /* __LOGGER_H__ */