Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
Joe Martin
OpenLDAP
Commits
eb734a16
Commit
eb734a16
authored
Dec 27, 2005
by
Pierangelo Masarati
Browse files
add severity-aware logging (ITS
#4282
)
parent
3897c50d
Changes
7
Hide whitespace changes
Inline
Side-by-side
configure
View file @
eb734a16
#! /bin/sh
# From configure.in OpenLDAP: pkg/ldap/configure.in,v 1.60
9
2005/1
1/26 16:04
:5
7
ando Exp .
# From configure.in OpenLDAP: pkg/ldap/configure.in,v 1.6
1
0 2005/1
2/16 15:52
:5
9
ando Exp .
# Guess values for system-dependent variables and create Makefiles.
# Generated by GNU Autoconf 2.59.
#
...
...
@@ -1006,7 +1006,7 @@ if test -n "$ac_init_help"; then
Optional Features:
--disable-FEATURE do not include FEATURE (same as --enable-FEATURE=no)
--enable-FEATURE[=ARG] include FEATURE [ARG=yes]
--enable-debug enable debugging [yes]
--enable-debug enable debugging
no|yes|traditional
[yes]
--enable-dynamic enable linking built binaries with dynamic libs [no]
--enable-syslog enable syslog support [auto]
--enable-proctitle enable proctitle support [yes]
...
...
@@ -2176,7 +2176,7 @@ if test "${enable_debug+set}" = set; then
enableval="$enable_debug"
ol_arg=invalid
for ol_val in
aut
o yes
no
; do
for ol_val in
n
o yes
traditional
; do
if test "$enableval" = "$ol_val" ; then
ol_arg="$ol_val"
fi
...
...
@@ -44024,6 +44024,13 @@ _ACEOF
fi
if test "$ol_enable_debug" != no ; then
if test "$ol_enable_debug" = traditional; then
cat >>confdefs.h <<\_ACEOF
#define OLD_DEBUG 1
_ACEOF
fi
cat >>confdefs.h <<\_ACEOF
#define LDAP_DEBUG 1
configure.in
View file @
eb734a16
...
...
@@ -222,7 +222,8 @@ AC_SUBST(ldap_subdir)dnl
dnl ----------------------------------------------------------------
dnl General "enable" options
OL_ARG_ENABLE(debug,[ --enable-debug enable debugging], yes)dnl
dnl set default to traditional to enable the original debug style
OL_ARG_ENABLE(debug,[ --enable-debug enable debugging], yes, [no yes traditional])dnl
OL_ARG_ENABLE(dynamic,[ --enable-dynamic enable linking built binaries with dynamic libs], no)dnl
OL_ARG_ENABLE(syslog,[ --enable-syslog enable syslog support], auto)dnl
OL_ARG_ENABLE(proctitle,[ --enable-proctitle enable proctitle support], yes)dnl
...
...
@@ -2640,6 +2641,10 @@ if test "$ol_enable_slapi" != no ; then
fi
if test "$ol_enable_debug" != no ; then
if test "$ol_enable_debug" = traditional; then
AC_DEFINE(OLD_DEBUG,1,
[define to use the original debug style])
fi
AC_DEFINE(LDAP_DEBUG,1,
[define this to add debugging code])
fi
...
...
include/ldap_log.h
View file @
eb734a16
...
...
@@ -23,8 +23,8 @@
* is provided ``as is'' without express or implied warranty.
*/
#ifndef
_
LDAP_LOG_H
#define
_
LDAP_LOG_H
#ifndef LDAP_LOG_H
#define LDAP_LOG_H
#include
<stdio.h>
#include
<ldap_cdefs.h>
...
...
@@ -39,19 +39,71 @@ LDAP_BEGIN_DECL
* debugging levels begin with LDAP_LEVEL_ENTRY
*
*/
#define LDAP_LEVEL_EMERG 0
#define LDAP_LEVEL_ALERT 1
#define LDAP_LEVEL_CRIT 2
#define LDAP_LEVEL_ERR 3
#define LDAP_LEVEL_WARNING 4
#define LDAP_LEVEL_NOTICE 5
#define LDAP_LEVEL_INFO 6
#define LDAP_LEVEL_ENTRY 7
/* log function entry points */
#define LDAP_LEVEL_ARGS 8
/* log function call parameters */
#define LDAP_LEVEL_RESULTS 9
/* Log function results */
#define LDAP_LEVEL_DETAIL1 10
/* log level 1 function operational details */
#define LDAP_LEVEL_DETAIL2 11
/* Log level 2 function operational details */
/*
* The "OLD_DEBUG" means that all logging occurs at LOG_DEBUG
*/
#ifdef OLD_DEBUG
/* original behavior: all logging occurs at the same severity level */
#if defined(LDAP_DEBUG) && defined(LDAP_SYSLOG)
#define LDAP_LEVEL_EMERG ldap_syslog_level
#define LDAP_LEVEL_ALERT ldap_syslog_level
#define LDAP_LEVEL_CRIT ldap_syslog_level
#define LDAP_LEVEL_ERR ldap_syslog_level
#define LDAP_LEVEL_WARNING ldap_syslog_level
#define LDAP_LEVEL_NOTICE ldap_syslog_level
#define LDAP_LEVEL_INFO ldap_syslog_level
#define LDAP_LEVEL_DEBUG ldap_syslog_level
#else
/* !LDAP_DEBUG || !LDAP_SYSLOG */
#define LDAP_LEVEL_EMERG (7)
#define LDAP_LEVEL_ALERT (7)
#define LDAP_LEVEL_CRIT (7)
#define LDAP_LEVEL_ERR (7)
#define LDAP_LEVEL_WARNING (7)
#define LDAP_LEVEL_NOTICE (7)
#define LDAP_LEVEL_INFO (7)
#define LDAP_LEVEL_DEBUG (7)
#endif
/* !LDAP_DEBUG || !LDAP_SYSLOG */
#else
/* ! OLD_DEBUG */
/* map syslog onto LDAP severity levels */
#ifdef LOG_DEBUG
#define LDAP_LEVEL_EMERG LOG_EMERG
#define LDAP_LEVEL_ALERT LOG_ALERT
#define LDAP_LEVEL_CRIT LOG_CRIT
#define LDAP_LEVEL_ERR LOG_ERR
#define LDAP_LEVEL_WARNING LOG_WARNING
#define LDAP_LEVEL_NOTICE LOG_NOTICE
#define LDAP_LEVEL_INFO LOG_INFO
#define LDAP_LEVEL_DEBUG LOG_DEBUG
#else
/* ! LOG_DEBUG */
#define LDAP_LEVEL_EMERG (0)
#define LDAP_LEVEL_ALERT (1)
#define LDAP_LEVEL_CRIT (2)
#define LDAP_LEVEL_ERR (3)
#define LDAP_LEVEL_WARNING (4)
#define LDAP_LEVEL_NOTICE (5)
#define LDAP_LEVEL_INFO (6)
#define LDAP_LEVEL_DEBUG (7)
#endif
/* ! LOG_DEBUG */
#endif
/* ! OLD_DEBUG */
#if 0
/* in case we need to reuse the unused bits of severity */
#define LDAP_LEVEL_MASK(s) ((s) & 0x7)
#else
#define LDAP_LEVEL_MASK(s) (s)
#endif
/* (yet) unused */
#define LDAP_LEVEL_ENTRY (0x08)
/* log function entry points */
#define LDAP_LEVEL_ARGS (0x10)
/* log function call parameters */
#define LDAP_LEVEL_RESULTS (0x20)
/* Log function results */
#define LDAP_LEVEL_DETAIL1 (0x40)
/* log level 1 function operational details */
#define LDAP_LEVEL_DETAIL2 (0x80)
/* Log level 2 function operational details */
/* end of (yet) unused */
/* original subsystem selection mechanism */
#define LDAP_DEBUG_TRACE 0x0001
#define LDAP_DEBUG_PACKETS 0x0002
#define LDAP_DEBUG_ARGS 0x0004
...
...
@@ -79,48 +131,103 @@ LDAP_BEGIN_DECL
* This is a bogus extern declaration for the compiler. No need to ensure
* a 'proper' dllimport.
*/
#
ifndef ldap_debug
extern
int
ldap_debug
;
#
endif
/* !ldap_debug */
#ifndef ldap_debug
extern
int
ldap_debug
;
#endif
/* !ldap_debug */
#
ifdef LDAP_SYSLOG
extern
int
ldap_syslog
;
extern
int
ldap_syslog_level
;
#ifdef LDAP_SYSLOG
extern
int
ldap_syslog
;
extern
int
ldap_syslog_level
;
#
ifdef HAVE_EBCDIC
#
define syslog eb_syslog
extern
void
eb_syslog
(
int
pri
,
const
char
*
fmt
,
...);
#
endif
#ifdef HAVE_EBCDIC
#define syslog eb_syslog
extern
void
eb_syslog
(
int
pri
,
const
char
*
fmt
,
...);
#endif
/* HAVE_EBCDIC */
#
endif
/* LDAP_SYSLOG */
#endif
/* LDAP_SYSLOG */
/* this doesn't below as part of ldap.h */
# ifdef LDAP_SYSLOG
# define Debug( level, fmt, arg1, arg2, arg3 ) \
#ifdef LDAP_SYSLOG
#define Log1( level, severity, fmt, arg1 ) \
do { \
if ( ldap_debug & (level) ) \
lutil_debug( ldap_debug, (level), (fmt), (arg1) ); \
if ( ldap_syslog & (level) ) \
syslog( LDAP_LEVEL_MASK((severity)), (fmt), (arg1) ); \
} while ( 0 )
#define Log2( level, severity, fmt, arg1, arg2 ) \
do { \
if ( ldap_debug & (level) ) \
lutil_debug( ldap_debug, (level), (fmt), (arg1), (arg2) ); \
if ( ldap_syslog & (level) ) \
syslog( LDAP_LEVEL_MASK((severity)), (fmt), (arg1), (arg2) ); \
} while ( 0 )
#define Log3( level, severity, fmt, arg1, arg2, arg3 ) \
do { \
if ( ldap_debug & (level) ) \
lutil_debug( ldap_debug, (level), (fmt), (arg1), (arg2), (arg3) ); \
if ( ldap_syslog & (level) ) \
syslog( ldap_syslog_level, (fmt), (arg1), (arg2), (arg3) ); \
syslog( LDAP_LEVEL_MASK((severity)), (fmt), (arg1), (arg2), (arg3) ); \
} while ( 0 )
#define Log4( level, severity, fmt, arg1, arg2, arg3, arg4 ) \
do { \
if ( ldap_debug & (level) ) \
lutil_debug( ldap_debug, (level), (fmt), (arg1), (arg2), (arg3), (arg4) ); \
if ( ldap_syslog & (level) ) \
syslog( LDAP_LEVEL_MASK((severity)), (fmt), (arg1), (arg2), (arg3), (arg4) ); \
} while ( 0 )
#define Log5( level, severity, fmt, arg1, arg2, arg3, arg4, arg5 ) \
do { \
if ( ldap_debug & (level) ) \
lutil_debug( ldap_debug, (level), (fmt), (arg1), (arg2), (arg3), (arg4), (arg5) ); \
if ( ldap_syslog & (level) ) \
syslog( LDAP_LEVEL_MASK((severity)), (fmt), (arg1), (arg2), (arg3), (arg4), (arg5) ); \
} while ( 0 )
#define Debug( level, fmt, arg1, arg2, arg3 ) \
Log3( (level), ldap_syslog_level, (fmt), (arg1), (arg2), (arg3) )
#define LogTest(level) ( ( ldap_debug | ldap_syslog ) & (level) )
# else
# define Debug( level, fmt, arg1, arg2, arg3 ) \
#else
/* ! LDAP_SYSLOG */
#define Log1( level, severity, fmt, arg1 ) \
do { \
if ( ldap_debug & (level) ) \
lutil_debug( ldap_debug, (level), (fmt), (arg1) ); \
} while ( 0 )
#define Log2( level, severity, fmt, arg1, arg2 ) \
do { \
if ( ldap_debug & (level) ) \
lutil_debug( ldap_debug, (level), (fmt), (arg1), (arg2) ); \
} while ( 0 )
#define Log3( level, severity, fmt, arg1, arg2, arg3 ) \
do { \
if ( ldap_debug & (level) ) \
lutil_debug( ldap_debug, (level), (fmt), (arg1), (arg2), (arg3) ); \
} while ( 0 )
# endif
#else
/* LDAP_DEBUG */
# define Debug( level, fmt, arg1, arg2, arg3 )
#endif
/* LDAP_DEBUG */
#ifndef LDAP_LOG
#define LDAP_LOG(a, b, fmt, arg1, arg2, arg3)
#define LDAP_LOGS_TEST(a, b) 0
#endif
#define Log4( level, severity, fmt, arg1, arg2, arg3, arg4 ) \
do { \
if ( ldap_debug & (level) ) \
lutil_debug( ldap_debug, (level), (fmt), (arg1), (arg2), (arg3), (arg4) ); \
} while ( 0 )
#define Log5( level, severity, fmt, arg1, arg2, arg3, arg4, arg5 ) \
do { \
if ( ldap_debug & (level) ) \
lutil_debug( ldap_debug, (level), (fmt), (arg1), (arg2), (arg3), (arg4), (arg5) ); \
} while ( 0 )
#define Debug( level, fmt, arg1, arg2, arg3 ) \
Log3( (level), (fmt), (arg1), (arg2), (arg3) )
#define LogTest(level) ( ldap_debug & (level) )
#endif
/* ! LDAP_SYSLOG */
#else
/* ! LDAP_DEBUG */
/* TODO: in case LDAP_DEBUG is undefined, make sure logs with appropriate
* severity gets thru anyway */
#define Log1( level, severity, fmt, arg1 )
#define Log2( level, severity, fmt, arg1, arg2 )
#define Log3( level, severity, fmt, arg1, arg2, arg3 )
#define Log4( level, severity, fmt, arg1, arg2, arg3, arg4 )
#define Log5( level, severity, fmt, arg1, arg2, arg3, arg4, arg5 )
#define Debug( level, fmt, arg1, arg2, arg3 )
#define LogTest(level) ( 0 )
#endif
/* ! LDAP_DEBUG */
LDAP_LUTIL_F
(
int
)
lutil_debug_file
LDAP_P
((
FILE
*
file
));
...
...
@@ -130,4 +237,4 @@ LDAP_LUTIL_F(void) lutil_debug LDAP_P((
LDAP_END_DECL
#endif
/*
_
LDAP_LOG_H */
#endif
/* LDAP_LOG_H */
include/portable.hin
View file @
eb734a16
...
...
@@ -891,6 +891,9 @@
/* define if you have (or want) no threads */
#undef NO_THREADS
/* define to use the original debug style */
#undef OLD_DEBUG
/* Package */
#undef OPENLDAP_PACKAGE
...
...
libraries/liblber/debug.c
View file @
eb734a16
...
...
@@ -34,23 +34,6 @@
static
FILE
*
log_file
=
NULL
;
#ifdef LDAP_SYSLOG
static
int
use_syslog
=
0
;
static
int
debug2syslog
(
int
l
)
{
switch
(
l
)
{
case
LDAP_LEVEL_EMERG
:
return
LOG_EMERG
;
case
LDAP_LEVEL_ALERT
:
return
LOG_ALERT
;
case
LDAP_LEVEL_CRIT
:
return
LOG_CRIT
;
case
LDAP_LEVEL_ERR
:
return
LOG_ERR
;
case
LDAP_LEVEL_WARNING
:
return
LOG_WARNING
;
case
LDAP_LEVEL_NOTICE
:
return
LOG_NOTICE
;
case
LDAP_LEVEL_INFO
:
return
LOG_INFO
;
}
return
LOG_DEBUG
;
}
#endif
int
lutil_debug_file
(
FILE
*
file
)
{
log_file
=
file
;
...
...
servers/slapd/main.c
View file @
eb734a16
...
...
@@ -182,7 +182,9 @@ parse_syslog_user( const char *arg, int *syslogUser )
int
i
=
verb_to_mask
(
optarg
,
syslogUsers
);
if
(
BER_BVISNULL
(
&
syslogUsers
[
i
].
word
)
)
{
Debug
(
LDAP_DEBUG_ANY
,
"unrecognized syslog user
\"
%s
\"
.
\n
"
,
optarg
,
0
,
0
);
Debug
(
LDAP_DEBUG_ANY
,
"unrecognized syslog user
\"
%s
\"
.
\n
"
,
optarg
,
0
,
0
);
return
1
;
}
...
...
@@ -192,6 +194,33 @@ parse_syslog_user( const char *arg, int *syslogUser )
}
#endif
/* LOG_LOCAL4 */
static
int
parse_syslog_level
(
const
char
*
arg
,
int
*
levelp
)
{
static
slap_verbmasks
str2syslog_level
[]
=
{
{
BER_BVC
(
"EMERG"
),
LOG_EMERG
},
{
BER_BVC
(
"ALERT"
),
LOG_ALERT
},
{
BER_BVC
(
"CRIT"
),
LOG_CRIT
},
{
BER_BVC
(
"ERR"
),
LOG_ERR
},
{
BER_BVC
(
"WARNING"
),
LOG_WARNING
},
{
BER_BVC
(
"NOTICE"
),
LOG_NOTICE
},
{
BER_BVC
(
"INFO"
),
LOG_INFO
},
{
BER_BVC
(
"DEBUG"
),
LOG_DEBUG
},
{
BER_BVNULL
,
0
}
};
int
i
=
verb_to_mask
(
arg
,
str2syslog_level
);
if
(
BER_BVISNULL
(
&
str2syslog_level
[
i
].
word
)
)
{
Debug
(
LDAP_DEBUG_ANY
,
"unknown syslog level
\"
%s
\"
.
\n
"
,
arg
,
0
,
0
);
return
1
;
}
*
levelp
=
str2syslog_level
[
i
].
mask
;
return
0
;
}
int
parse_debug_level
(
const
char
*
arg
,
int
*
levelp
)
{
...
...
@@ -400,11 +429,14 @@ int main( int argc, char **argv )
#ifdef HAVE_CHROOT
"r:"
#endif
#ifdef LDAP_SYSLOG
"S:"
#endif
#ifdef LOG_LOCAL4
"l:"
"l:"
#endif
#if defined(HAVE_SETUID) && defined(HAVE_SETGID)
"u:g:"
"u:g:"
#endif
))
!=
EOF
)
{
switch
(
i
)
{
...
...
@@ -514,6 +546,14 @@ int main( int argc, char **argv )
}
break
;
#if defined(LDAP_DEBUG) && defined(LDAP_SYSLOG)
case
'S'
:
if
(
parse_syslog_level
(
optarg
,
&
ldap_syslog_level
)
)
{
goto
destroy
;
}
break
;
#endif
/* LDAP_DEBUG && LDAP_SYSLOG */
#ifdef LOG_LOCAL4
case
'l'
:
/* set syslog local user */
if
(
parse_syslog_user
(
optarg
,
&
syslogUser
)
)
{
...
...
servers/slapd/slap.h
View file @
eb734a16
...
...
@@ -2675,16 +2675,75 @@ typedef struct slap_conn {
}
Connection
;
#if defined(LDAP_SYSLOG) && defined(LDAP_DEBUG)
#define Statslog( level, fmt, connid, opid, arg1, arg2, arg3 ) \
#define Statslog1( level, severity, fmt, connid, opid, arg1 ) \
do { \
if ( ldap_debug & (level) ) \
fprintf( stderr, (fmt), (connid), (opid), (arg1) );\
if ( ldap_syslog & (level) ) \
syslog( LDAP_LEVEL_MASK((severity)), (fmt), (connid), (opid), \
(arg1) ); \
} while (0)
#define Statslog2( level, severity, fmt, connid, opid, arg1, arg2 ) \
do { \
if ( ldap_debug & (level) ) \
fprintf( stderr, (fmt), (connid), (opid), (arg1), (arg2) );\
if ( ldap_syslog & (level) ) \
syslog( LDAP_LEVEL_MASK((severity)), (fmt), (connid), (opid), \
(arg1), (arg2) ); \
} while (0)
#define Statslog3( level, severity, fmt, connid, opid, arg1, arg2, arg3 ) \
do { \
if ( ldap_debug & (level) ) \
fprintf( stderr, (fmt), (connid), (opid), (arg1), (arg2), (arg3) );\
if ( ldap_syslog & (level) ) \
syslog( ldap_syslog_level, (fmt), (connid), (opid), (arg1), \
(arg2), (arg3) ); \
syslog( LDAP_LEVEL_MASK((severity)), (fmt), (connid), (opid), \
(arg1), (arg2), (arg3) ); \
} while (0)
#define Statslog4( level, severity, fmt, connid, opid, arg1, arg2, arg3, arg4 ) \
do { \
if ( ldap_debug & (level) ) \
fprintf( stderr, (fmt), (connid), (opid), (arg1), (arg2), (arg3), (arg4) );\
if ( ldap_syslog & (level) ) \
syslog( LDAP_LEVEL_MASK((severity)), (fmt), (connid), (opid), \
(arg1), (arg2), (arg3), (arg4) ); \
} while (0)
#define Statslog5( level, severity, fmt, connid, opid, arg1, arg2, arg3, arg4, arg5 ) \
do { \
if ( ldap_debug & (level) ) \
fprintf( stderr, (fmt), (connid), (opid), (arg1), (arg2), (arg3), (arg4), (arg5) );\
if ( ldap_syslog & (level) ) \
syslog( LDAP_LEVEL_MASK((severity)), (fmt), (connid), (opid), \
(arg1), (arg2), (arg3), (arg4), (arg5) ); \
} while (0)
#define Statslog( level, fmt, connid, opid, arg1, arg2, arg3 ) \
Statslog3( (level), ldap_syslog_level, (fmt), (connid), (opid), (arg1), (arg2), (arg3) )
#define StatslogTest( level ) ((ldap_debug | ldap_syslog) & (level))
#elif defined(LDAP_DEBUG)
#define Statslog1( level, severity, fmt, connid, opid, arg1 ) \
do { \
if ( ldap_debug & (level) ) \
fprintf( stderr, (fmt), (connid), (opid), (arg1) );\
} while (0)
#define Statslog2( level, severity, fmt, connid, opid, arg1, arg2 ) \
do { \
if ( ldap_debug & (level) ) \
fprintf( stderr, (fmt), (connid), (opid), (arg1), (arg2) );\
} while (0)
#define Statslog3( level, severity, fmt, connid, opid, arg1, arg2, arg3 ) \
do { \
if ( ldap_debug & (level) ) \
fprintf( stderr, (fmt), (connid), (opid), (arg1), (arg2), (arg3) );\
} while (0)
#define Statslog4( level, severity, fmt, connid, opid, arg1, arg2, arg3, arg4 ) \
do { \
if ( ldap_debug & (level) ) \
fprintf( stderr, (fmt), (connid), (opid), (arg1), (arg2), (arg3), (arg4) );\
} while (0)
#define Statslog5( level, severity, fmt, connid, opid, arg1, arg2, arg3, arg4, arg5 ) \
do { \
if ( ldap_debug & (level) ) \
fprintf( stderr, (fmt), (connid), (opid), (arg1), (arg2), (arg3), (arg4), (arg5) );\
} while (0)
#define Statslog( level, fmt, connid, opid, arg1, arg2, arg3 ) \
do { \
if ( ldap_debug & (level) ) \
...
...
@@ -2692,6 +2751,11 @@ typedef struct slap_conn {
} while (0)
#define StatslogTest( level ) (ldap_debug & (level))
#else
#define Statslog1( level, severity, fmt, connid, opid, arg1 )
#define Statslog2( level, severity, fmt, connid, opid, arg1, arg2 )
#define Statslog3( level, severity, fmt, connid, opid, arg1, arg2, arg3 )
#define Statslog4( level, severity, fmt, connid, opid, arg1, arg2, arg3, arg4 )
#define Statslog5( level, severity, fmt, connid, opid, arg1, arg2, arg3, arg4, arg5 )
#define Statslog( level, fmt, connid, opid, arg1, arg2, arg3 )
#define StatslogTest( level ) (0)
#endif
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment