3 * Copyright 1998-2002 The OpenLDAP Foundation, Redwood City, California, USA
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.
13 * Copyright (c) 1990 Regents of the University of Michigan.
14 * All rights reserved.
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.
28 #include <ldap_cdefs.h>
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.
38 #define LDAP_SUBSYS_NUM 20
39 #define LDAP_SUBSYS_MAX 19
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_BER 5
47 #define LDAP_SUBSYS_CONFIG 6
48 #define LDAP_SUBSYS_ACL 7
49 #define LDAP_SUBSYS_CACHE 8
50 #define LDAP_SUBSYS_INDEX 9
51 #define LDAP_SUBSYS_LDIF 10
52 #define LDAP_SUBSYS_TOOLS 11
53 #define LDAP_SUBSYS_SLAPD 12
54 #define LDAP_SUBSYS_SLURPD 13
55 #define LDAP_SUBSYS_BACKEND 14
56 #define LDAP_SUBSYS_BACK_BDB 15
57 #define LDAP_SUBSYS_BACK_LDBM 16
58 #define LDAP_SUBSYS_BACK_LDAP 17
59 #define LDAP_SUBSYS_BACK_META 18
60 #define LDAP_SUBSYS_BACK_MON 19
63 * debug reporting levels.
65 * They start with the syslog levels, and
66 * go down in importance. The normal
67 * debugging levels begin with LDAP_LEVEL_ENTRY
70 #define LDAP_LEVEL_EMERG 0
71 #define LDAP_LEVEL_ALERT 1
72 #define LDAP_LEVEL_CRIT 2
73 #define LDAP_LEVEL_ERR 3
74 #define LDAP_LEVEL_WARNING 4
75 #define LDAP_LEVEL_NOTICE 5
76 #define LDAP_LEVEL_INFO 6
77 #define LDAP_LEVEL_ENTRY 7 /* log function entry points */
78 #define LDAP_LEVEL_ARGS 8 /* log function call parameters */
79 #define LDAP_LEVEL_RESULTS 9 /* Log function results */
80 #define LDAP_LEVEL_DETAIL1 10 /* log level 1 function operational details */
81 #define LDAP_LEVEL_DETAIL2 11 /* Log level 2 function operational details */
83 #define LDAP_DEBUG_TRACE 0x0001
84 #define LDAP_DEBUG_PACKETS 0x0002
85 #define LDAP_DEBUG_ARGS 0x0004
86 #define LDAP_DEBUG_CONNS 0x0008
87 #define LDAP_DEBUG_BER 0x0010
88 #define LDAP_DEBUG_FILTER 0x0020
89 #define LDAP_DEBUG_CONFIG 0x0040
90 #define LDAP_DEBUG_ACL 0x0080
91 #define LDAP_DEBUG_STATS 0x0100
92 #define LDAP_DEBUG_STATS2 0x0200
93 #define LDAP_DEBUG_SHELL 0x0400
94 #define LDAP_DEBUG_PARSE 0x0800
95 #define LDAP_DEBUG_CACHE 0x1000
96 #define LDAP_DEBUG_INDEX 0x2000
98 #define LDAP_DEBUG_DEPRECATED 0x1000
99 #define LDAP_DEBUG_NONE 0x8000
100 #define LDAP_DEBUG_ANY -1
102 /* debugging stuff */
106 * This is a bogus extern declaration for the compiler. No need to ensure
107 * a 'proper' dllimport.
110 extern int ldap_debug;
111 # endif /* !ldap_debug */
114 extern int ldap_syslog;
115 extern int ldap_syslog_level;
116 # endif /* LDAP_SYSLOG */
118 /* this doesn't below as part of ldap.h */
120 # define Debug( level, fmt, arg1, arg2, arg3 ) \
122 if ( ldap_debug & (level) ) \
123 lutil_debug( ldap_debug, (level), (fmt), (arg1), (arg2), (arg3) ); \
124 if ( ldap_syslog & (level) ) \
125 syslog( ldap_syslog_level, (fmt), (arg1), (arg2), (arg3) ); \
129 # define Debug( level, fmt, arg1, arg2, arg3 ) \
131 if ( ldap_debug & (level) ) \
132 lutil_debug( ldap_debug, (level), (fmt), (arg1), (arg2), (arg3) ); \
136 #else /* LDAP_DEBUG */
137 # define Debug( level, fmt, arg1, arg2, arg3 )
139 #endif /* LDAP_DEBUG */
142 extern int ldap_loglevels[LDAP_SUBSYS_NUM];
143 #define LDAP_LOG(a, b, fmt, arg1, arg2, arg3) do {\
144 if (ldap_loglevels[LDAP_SUBSYS_##a] >= LDAP_LEVEL_##b || \
145 ldap_loglevels[LDAP_SUBSYS_GLOBAL] >= LDAP_LEVEL_##b)\
146 lutil_log (LDAP_SUBSYS_##a, LDAP_LEVEL_##b, fmt, arg1, arg2, arg3); \
150 #define LDAP_LOGS_TEST(a, b) \
151 (ldap_loglevels[LDAP_SUBSYS_##a] >= LDAP_LEVEL_##b || \
152 ldap_loglevels[LDAP_SUBSYS_GLOBAL] >= LDAP_LEVEL_##b)
154 #endif /* LDAP_LOG */
157 #define LDAP_LOG(a, b, fmt, arg1, arg2, arg3)
160 LDAP_LUTIL_F(int) lutil_mnem2level LDAP_P(( const char *level ));
161 LDAP_LUTIL_F(void) lutil_log_initialize LDAP_P((
162 int argc, char **argv ));
163 LDAP_LUTIL_F(int) lutil_set_debug_level LDAP_P((
164 const char *subsys, int level ));
165 LDAP_LUTIL_F(void) lutil_log LDAP_P((
166 const int subsys, int level, const char *fmt, ... ));
168 LDAP_LUTIL_F(int) lutil_debug_file LDAP_P(( FILE *file ));
171 LDAP_LUTIL_F(void) lutil_debug LDAP_P((
172 int debug, int level,
173 const char* fmt, ... )) LDAP_GCCATTR((format(printf, 3, 4)));
177 #endif /* _LDAP_LOG_H */