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