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