3 * Copyright 1998-2001 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 12
39 #define LDAP_SUBSYS_MAX 11
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
55 * debug reporting levels.
57 * They start with the syslog levels, and
58 * go down in importance. The normal
59 * debugging levels begin with LDAP_LEVEL_ENTRY
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 */
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
90 #define LDAP_DEBUG_DEPRECATED 0x1000
91 #define LDAP_DEBUG_NONE 0x8000
92 #define LDAP_DEBUG_ANY -1
98 * This is a bogus extern declaration for the compiler. No need to ensure
99 * a 'proper' dllimport.
102 extern int ldap_debug;
103 # endif /* !ldap_debug */
106 extern int ldap_syslog;
107 extern int ldap_syslog_level;
108 # endif /* LDAP_SYSLOG */
110 /* this doesn't below as part of ldap.h */
112 # define Debug( level, fmt, arg1, arg2, arg3 ) \
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) ); \
121 # define Debug( level, fmt, arg1, arg2, arg3 ) \
123 if ( ldap_debug & (level) ) \
124 lutil_debug( ldap_debug, (level), (fmt), (arg1), (arg2), (arg3) ); \
129 # define LDAP_LOG(a) lutil_log a
132 #else /* LDAP_DEBUG */
133 # define Debug( level, fmt, arg1, arg2, arg3 )
139 #endif /* LDAP_DEBUG */
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, ... ));
150 LDAP_LUTIL_F(int) lutil_debug_file LDAP_P(( FILE *file ));
153 LDAP_LUTIL_F(void) lutil_debug LDAP_P((
154 int debug, int level,
155 const char* fmt, ... )) LDAP_GCCATTR((format(printf, 3, 4)));
159 #endif /* _LDAP_LOG_H */