*** empty log message ***
[tinc] / lib / logging.h
1 /*
2     logging.h -- header for logging.c
3     Copyright (C) 2002 Guus Sliepen <guus@sliepen.warande.net>,
4                   2002 Ivo Timmermans <ivo@o2w.nl>
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: logging.h,v 1.1 2002/04/28 12:46:25 zarq Exp $
21 */
22
23 #ifndef __TINC_LOGGING_H__
24 #define __TINC_LOGGING_H__
25
26 #include <stdarg.h>
27
28 enum {
29   TLOG_DEBUG,
30   TLOG_INFO,
31   TLOG_NOTICE,
32   TLOG_ERROR,
33   TLOG_CRITICAL
34 };
35
36 enum {
37   DEBUG_NOTHING = 0,            /* Quiet mode, only show starting/stopping of the daemon */
38   DEBUG_CONNECTIONS = 1,        /* Show (dis)connects of other tinc daemons via TCP */
39   DEBUG_ERROR = 2,              /* Show error messages received from other hosts */
40   DEBUG_STATUS = 2,             /* Show status messages received from other hosts */
41   DEBUG_PROTOCOL = 3,           /* Show the requests that are sent/received */
42   DEBUG_META = 4,               /* Show contents of every request that is sent/received */
43   DEBUG_TRAFFIC = 5,            /* Show network traffic information */
44   DEBUG_PACKET = 6,             /* Show contents of each packet that is being sent/received */
45   DEBUG_SCARY_THINGS = 10       /* You have been warned */
46 };
47
48 typedef void (log_function_t)(int,int,char*,va_list);
49
50 extern int debug_lvl;
51 extern avl_tree_t *log_hooks_tree;
52
53 extern void log(int, int, char *, ...);
54 extern void log_add_hook(log_function_t *);
55 extern void log_del_hook(log_function_t *);
56 extern log_function_t log_default;
57 extern log_function_t log_syslog;
58 extern void tinc_syslog(int, char *, ...);
59
60 #ifndef LOG_ERR /* Something from syslog.h */
61 # define syslog tinc_syslog
62 #define LOG_EMERG       0       /* system is unusable */
63 #define LOG_ALERT       1       /* action must be taken immediately */
64 #define LOG_CRIT        2       /* critical conditions */
65 #define LOG_ERR         3       /* error conditions */
66 #define LOG_WARNING     4       /* warning conditions */
67 #define LOG_NOTICE      5       /* normal but significant condition */
68 #define LOG_INFO        6       /* informational */
69 #define LOG_DEBUG       7       /* debug-level messages */
70 #else
71 # warning dont include syslog!
72 #endif
73
74 #endif /* __TINC_LOGGING_H__ */