]> git.sur5r.net Git - openldap/blob - include/ldap_log.h
beautify listener monitor
[openldap] / include / ldap_log.h
1 /* $OpenLDAP$ */
2 /*
3  * Copyright 1998-2002 The OpenLDAP Foundation, Redwood City, California, USA
4  * All rights reserved.
5  *
6  * Redistribution and use in source and binary forms, with or without
7  * modification, are permitted only as authorized by the OpenLDAP
8  * Public License.  A copy of this license is available at
9  * http://www.OpenLDAP.org/license.html or in file LICENSE in the
10  * top-level directory of the distribution.
11  */
12 /* Portions
13  * Copyright (c) 1990 Regents of the University of Michigan.
14  * All rights reserved.
15  *
16  * Redistribution and use in source and binary forms are permitted
17  * provided that this notice is preserved and that due credit is given
18  * to the University of Michigan at Ann Arbor. The name of the University
19  * may not be used to endorse or promote products derived from this
20  * software without specific prior written permission. This software
21  * is provided ``as is'' without express or implied warranty.
22  */
23
24 #ifndef _LDAP_LOG_H
25 #define _LDAP_LOG_H
26
27 #include <stdio.h>
28 #include <ldap_cdefs.h>
29
30 LDAP_BEGIN_DECL
31
32 /*
33  * While it's not important that the subsystem number are
34  * contiguous, it is important that the LDAP_SUBSYS_NUM accurately
35  * reflect the number of subsystems and LDAP_SUBSYS_MAX reflect
36  * the largest subsystem number.
37  */
38 #define LDAP_SUBSYS_NUM 12
39 #define LDAP_SUBSYS_MAX 11
40
41 #define LDAP_SUBSYS_GLOBAL      0
42 #define LDAP_SUBSYS_OPERATION   1
43 #define LDAP_SUBSYS_TRANSPORT   2
44 #define LDAP_SUBSYS_CONNECTION  3
45 #define LDAP_SUBSYS_FILTER      4
46 #define LDAP_SUBSYS_BACKEND     5
47 #define LDAP_SUBSYS_BER         6
48 #define LDAP_SUBSYS_CONFIG      7
49 #define LDAP_SUBSYS_ACL         8
50 #define LDAP_SUBSYS_CACHE       9
51 #define LDAP_SUBSYS_INDEX      10
52 #define LDAP_SUBSYS_LDIF       11
53
54 /*
55  * debug reporting levels.
56  *
57  * They start with the syslog levels, and
58  * go down in importance.  The normal
59  * debugging levels begin with LDAP_LEVEL_ENTRY
60  *
61  */
62 #define LDAP_LEVEL_EMERG       0
63 #define LDAP_LEVEL_ALERT       1
64 #define LDAP_LEVEL_CRIT        2
65 #define LDAP_LEVEL_ERR         3
66 #define LDAP_LEVEL_WARNING     4
67 #define LDAP_LEVEL_NOTICE      5
68 #define LDAP_LEVEL_INFO        6
69 #define LDAP_LEVEL_ENTRY       7  /* log function entry points */
70 #define LDAP_LEVEL_ARGS        8  /* log function call parameters */
71 #define LDAP_LEVEL_RESULTS     9  /* Log function results */
72 #define LDAP_LEVEL_DETAIL1    10  /* log level 1 function operational details */
73 #define LDAP_LEVEL_DETAIL2    11  /* Log level 2 function operational details */
74
75 #define LDAP_DEBUG_TRACE        0x0001
76 #define LDAP_DEBUG_PACKETS      0x0002
77 #define LDAP_DEBUG_ARGS         0x0004
78 #define LDAP_DEBUG_CONNS        0x0008
79 #define LDAP_DEBUG_BER          0x0010
80 #define LDAP_DEBUG_FILTER       0x0020
81 #define LDAP_DEBUG_CONFIG       0x0040
82 #define LDAP_DEBUG_ACL          0x0080
83 #define LDAP_DEBUG_STATS        0x0100
84 #define LDAP_DEBUG_STATS2       0x0200
85 #define LDAP_DEBUG_SHELL        0x0400
86 #define LDAP_DEBUG_PARSE        0x0800
87 #define LDAP_DEBUG_CACHE    0x1000
88 #define LDAP_DEBUG_INDEX    0x2000
89
90 #define LDAP_DEBUG_DEPRECATED   0x1000
91 #define LDAP_DEBUG_NONE         0x8000
92 #define LDAP_DEBUG_ANY          -1
93
94 /* debugging stuff */
95 #ifdef LDAP_DEBUG
96
97     /*
98      * This is a bogus extern declaration for the compiler. No need to ensure
99      * a 'proper' dllimport.
100      */
101 #   ifndef ldap_debug
102      extern int ldap_debug;
103 #   endif /* !ldap_debug */
104
105 #   ifdef LDAP_SYSLOG
106     extern int  ldap_syslog;
107     extern int  ldap_syslog_level;
108 #   endif /* LDAP_SYSLOG */
109
110 /* this doesn't below as part of ldap.h */
111 #   ifdef LDAP_SYSLOG
112 #   define Debug( level, fmt, arg1, arg2, arg3 )        \
113         do { \
114                 if ( ldap_debug & (level) ) \
115                         lutil_debug( ldap_debug, (level), (fmt), (arg1), (arg2), (arg3) ); \
116                 if ( ldap_syslog & (level) ) \
117                         syslog( ldap_syslog_level, (fmt), (arg1), (arg2), (arg3) ); \
118         } while ( 0 )
119
120 #   else
121 #       define Debug( level, fmt, arg1, arg2, arg3 ) \
122         do { \
123                 if ( ldap_debug & (level) ) \
124                         lutil_debug( ldap_debug, (level), (fmt), (arg1), (arg2), (arg3) ); \
125         } while ( 0 )
126 #   endif
127
128 #ifndef LDAP_LOG
129 #   define LDAP_LOG(a) lutil_log a
130 #endif
131
132 #else /* LDAP_DEBUG */
133 #   define Debug( level, fmt, arg1, arg2, arg3 )
134
135 #ifndef LDAP_LOG
136 #   define LDAP_LOG(a)
137 #endif
138
139 #endif /* LDAP_DEBUG */
140
141
142 LDAP_LUTIL_F(int) lutil_mnem2level LDAP_P(( const char *level ));
143 LDAP_LUTIL_F(void) lutil_log_initialize LDAP_P((
144         int argc, char **argv ));
145 LDAP_LUTIL_F(void) lutil_set_debug_level LDAP_P((
146         const char *subsys, int level ));
147 LDAP_LUTIL_F(void) lutil_log LDAP_P((
148         const char *subsys, int level, const char *fmt, ... ));
149
150 LDAP_LUTIL_F(int) lutil_debug_file LDAP_P(( FILE *file ));
151
152
153 LDAP_LUTIL_F(void) lutil_debug LDAP_P((
154         int debug, int level,
155         const char* fmt, ... )) LDAP_GCCATTR((format(printf, 3, 4)));
156
157 LDAP_END_DECL
158
159 #endif /* _LDAP_LOG_H */