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_NONE 0x8000
99 #define LDAP_DEBUG_ANY -1
101 /* debugging stuff */
105 * This is a bogus extern declaration for the compiler. No need to ensure
106 * a 'proper' dllimport.
109 extern int ldap_debug;
110 # endif /* !ldap_debug */
113 extern int ldap_syslog;
114 extern int ldap_syslog_level;
115 # endif /* LDAP_SYSLOG */
117 /* this doesn't below as part of ldap.h */
119 # define Debug( level, fmt, arg1, arg2, arg3 ) \
121 if ( ldap_debug & (level) ) \
122 lutil_debug( ldap_debug, (level), (fmt), (arg1), (arg2), (arg3) ); \
123 if ( ldap_syslog & (level) ) \
124 syslog( ldap_syslog_level, (fmt), (arg1), (arg2), (arg3) ); \
128 # define Debug( level, fmt, arg1, arg2, arg3 ) \
130 if ( ldap_debug & (level) ) \
131 lutil_debug( ldap_debug, (level), (fmt), (arg1), (arg2), (arg3) ); \
135 #else /* LDAP_DEBUG */
136 # define Debug( level, fmt, arg1, arg2, arg3 )
138 #endif /* LDAP_DEBUG */
141 extern int ldap_loglevels[LDAP_SUBSYS_NUM];
142 #define LDAP_LOG(a, b, fmt, arg1, arg2, arg3) do {\
143 if (ldap_loglevels[LDAP_SUBSYS_##a] >= LDAP_LEVEL_##b || \
144 ldap_loglevels[LDAP_SUBSYS_GLOBAL] >= LDAP_LEVEL_##b)\
145 lutil_log (LDAP_SUBSYS_##a, LDAP_LEVEL_##b, fmt, arg1, arg2, arg3); \
149 #define LDAP_LOGS_TEST(a, b) \
150 (ldap_loglevels[LDAP_SUBSYS_##a] >= LDAP_LEVEL_##b || \
151 ldap_loglevels[LDAP_SUBSYS_GLOBAL] >= LDAP_LEVEL_##b)
153 #endif /* LDAP_LOG */
156 #define LDAP_LOG(a, b, fmt, arg1, arg2, arg3)
159 LDAP_LUTIL_F(int) lutil_mnem2level LDAP_P(( const char *level ));
160 LDAP_LUTIL_F(void) lutil_log_initialize LDAP_P((
161 int argc, char **argv ));
162 LDAP_LUTIL_F(int) lutil_set_debug_level LDAP_P((
163 const char *subsys, int level ));
164 LDAP_LUTIL_F(void) lutil_log LDAP_P((
165 const int subsys, int level, const char *fmt, ... ));
167 LDAP_LUTIL_F(int) lutil_debug_file LDAP_P(( FILE *file ));
170 LDAP_LUTIL_F(void) lutil_debug LDAP_P((
171 int debug, int level,
172 const char* fmt, ... )) LDAP_GCCATTR((format(printf, 3, 4)));
176 #endif /* _LDAP_LOG_H */