1 /* Copyright (C) 2000-2015 Lavtech.com corp. All rights reserved.
2 
3    This program is free software; you can redistribute it and/or modify
4    it under the terms of the GNU General Public License as published by
5    the Free Software Foundation; either version 2 of the License, or
6    (at your option) any later version.
7 
8    This program is distributed in the hope that it will be useful,
9    but WITHOUT ANY WARRANTY; without even the implied warranty of
10    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11    GNU General Public License for more details.
12 
13    You should have received a copy of the GNU General Public License
14    along with this program; if not, write to the Free Software
15    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
16 */
17 
18 #ifndef _UDM_LOG_H
19 #define _UDM_LOG_H
20 
21 #include "udm_config.h"
22 #include "udm_common.h" /* for UDM_ENV etc. */
23 #ifdef HAVE_SYSLOG_H
24 #include <syslog.h>
25 #endif
26 
27 /* Define default log facility */
28 #ifdef HAVE_SYSLOG_H
29 #ifndef LOG_FACILITY
30 #define LOG_FACILITY LOG_LOCAL7
31 #endif /* LOG_FACILITY */
32 #else
33 #define LOG_FACILITY 0
34 #endif
35 
36 #define UDM_LOG_FACILITY_NONE -123 /* Just some magic number */
37 
38 
39 /* According to some recommendations, try not to exceed about 800 bytes
40    or you might have problems with old syslog implementations */
41 #define UDM_LOG_BUF_LEN 255
42 
43 /* Verbose levels */
44 #define UDM_LOG_NONE	0
45 #define UDM_LOG_ERROR	1
46 #define UDM_LOG_WARN	2
47 #define UDM_LOG_INFO	3
48 #define UDM_LOG_EXTRA	4
49 #define UDM_LOG_DEBUG	5
50 
51 int UdmOpenLog(const char * appname,UDM_ENV *Env, int log2stderr);
52 void UdmLog(UDM_AGENT *Agent, int level, const char *fmt, ...)
53             __attribute__((format(printf,3,4)));
54 /* if you do not have UDM_AGENT struct yet, use UdmEnvLog() */
55 void UdmEnvLog(UDM_ENV *Env, int level, const char *fmt, ...)
56                __attribute__((format(printf,3,4)));
57 
58 UDM_API(void) UdmEnvSetLogLevel(UDM_ENV *Env, int level);
59 UDM_API(void) UdmEnvIncLogLevel(UDM_ENV *A);
60 UDM_API(void) UdmEnvDecLogLevel(UDM_ENV *A);
61 UDM_API(void) UdmSetThreadProc(UDM_ENV * Conf,void (*_ThreadInfo)(UDM_AGENT* A,const char *state, const char* str));
62 UDM_API(void) UdmSetRefProc(UDM_ENV * Conf,void (*_RefProc)(int code,const char *url, const char *ref));
63 UDM_API(int)  UdmNeedLog(const UDM_ENV *Env, int level);
64 UDM_API(void) UdmShowThreadInfo(UDM_AGENT* A,const char *state, const char* str);
65 #endif /* _UDM_LOG_H */
66