1 /*
2     Copyright (C) 2002-2008  Thomas Ries <tries@gmx.net>
3 
4     This file is part of Siproxd.
5 
6     Siproxd 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     Siproxd 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 Siproxd; if not, write to the Free Software
18     Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
19 */
20 
21 /* $Id: log.h 369 2008-01-19 16:07:14Z hb9xar $ */
22 
23 #include <stdarg.h>
24 
25 #define DBCLASS_BABBLE	0x00000001	/* babble (like entering/leaving fnc)*/
26 #define DBCLASS_NET	0x00000002	/* network			     */
27 #define DBCLASS_SIP	0x00000004	/* SIP manipulations		     */
28 #define DBCLASS_REG	0x00000008	/* Client registration		     */
29 #define DBCLASS_NOSPEC	0x00000010	/* non specified class		     */
30 #define DBCLASS_PROXY	0x00000020	/* proxy			     */
31 #define DBCLASS_DNS	0x00000040	/* DNS stuff			     */
32 #define DBCLASS_NETTRAF	0x00000080	/* network traffic		     */
33 #define DBCLASS_CONFIG	0x00000100	/* configuration		     */
34 #define DBCLASS_RTP	0x00000200	/* RTP proxy			     */
35 #define DBCLASS_ACCESS	0x00000400	/* Access list evaluation	     */
36 #define DBCLASS_AUTH	0x00000800	/* Authentication		     */
37 #define DBCLASS_PLUGIN	0x00001000	/* Plugins			     */
38 #define DBCLASS_RTPBABL	0x00002000	/* RTP babble			     */
39 #define DBCLASS_ALL	0xffffffff	/* All classes			     */
40 
41 void log_init(void);
42 void log_end(void);
43 
44 void log_set_pattern(unsigned int pattern);
45 unsigned int  log_get_pattern(void);
46 void log_set_stderr(int tostdout);
47 void log_set_silence(int level);
48 void log_set_listen_port(int port);
49 void log_tcp_listen(void);
50 void log_tcp_connect(void);
51 
52 #if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ > 4)
53 #  define GNUC_PRINTF(format_idx, arg_idx) \
54      __attribute__((__format__ (__printf__, format_idx, arg_idx)))
55 #else
56 #  define GNUC_PRINTF(format_idx, arg_idx)
57 #endif
58 
59 #undef DEBUG
60 #define DEBUG(F...) log_debug(1,__FILE__, __LINE__,F)
61 
62 #define DEBUGC(C,F...) log_debug(C,__FILE__, __LINE__,F)
63 void log_debug(unsigned int class, char *file, int line, const char *format, ...) GNUC_PRINTF(4, 5);
64 
65 #define ERROR(F...) log_error(__FILE__, __LINE__,F)
66 void log_error(char *file, int line, const char *format, ...) GNUC_PRINTF(3, 4);
67 
68 #define WARN(F...) log_warn(__FILE__, __LINE__,F)
69 void log_warn(char *file, int line, const char *format, ...) GNUC_PRINTF(3, 4);
70 
71 #define INFO(F...) log_info(__FILE__, __LINE__,F)
72 void log_info(char *file, int line, const char *format, ...) GNUC_PRINTF(3, 4);
73 
74 /* tobedone: dump a buffer */
75 #define DUMP_BUFFER(C,F,L) log_dump_buffer(C,__FILE__, __LINE__,F,L)
76 void log_dump_buffer(unsigned int class, char *file, int line,
77                      char *buffer, int length);
78