X-Git-Url: https://git.sur5r.net/?a=blobdiff_plain;f=include%2Fldap_log.h;h=da004851d08a8fd7cf7f1160dbcf060162fd3a89;hb=113538806ffcdd83da45ad39d0ab54d515ffb1ae;hp=f81d57752d8174ec4437a4643eb7330cecb410db;hpb=6f68a1af6d2abd50969a9810906214183adc4740;p=openldap diff --git a/include/ldap_log.h b/include/ldap_log.h index f81d57752d..da004851d0 100644 --- a/include/ldap_log.h +++ b/include/ldap_log.h @@ -1,7 +1,7 @@ /* $OpenLDAP$ */ /* This work is part of OpenLDAP Software . * - * Copyright 1998-2005 The OpenLDAP Foundation. + * Copyright 1998-2012 The OpenLDAP Foundation. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -123,7 +123,7 @@ LDAP_BEGIN_DECL #define LDAP_DEBUG_SYNC 0x4000 #define LDAP_DEBUG_NONE 0x8000 -#define LDAP_DEBUG_ANY -1 +#define LDAP_DEBUG_ANY (-1) /* debugging stuff */ #ifdef LDAP_DEBUG @@ -148,106 +148,75 @@ extern void eb_syslog(int pri, const char *fmt, ...); /* this doesn't below as part of ldap.h */ #ifdef LDAP_SYSLOG -#define Log0( level, severity, fmt ) \ - do { \ - if ( ldap_debug & (level) ) \ - lutil_debug( ldap_debug, (level), (fmt) ); \ - if ( ldap_syslog & (level) ) \ - syslog( LDAP_LEVEL_MASK((severity)), (fmt) ); \ - } while ( 0 ) -#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_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 ) \ + +#define LogTest(level) ( ( ldap_debug | ldap_syslog ) & (level) ) +#define LogExpand(level, severity, args) \ do { \ if ( ldap_debug & (level) ) \ - lutil_debug( ldap_debug, (level), (fmt), (arg1), (arg2), (arg3), (arg4), (arg5) ); \ + lutil_debug( ldap_debug, (level), args ); \ if ( ldap_syslog & (level) ) \ - syslog( LDAP_LEVEL_MASK((severity)), (fmt), (arg1), (arg2), (arg3), (arg4), (arg5) ); \ + syslog( LDAP_LEVEL_MASK((severity)), args ); \ } 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 /* ! LDAP_SYSLOG */ -#define Log0( level, severity, fmt ) \ - do { \ - if ( ldap_debug & (level) ) \ - lutil_debug( ldap_debug, (level), (fmt) ); \ - } while ( 0 ) -#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 ) -#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 ) \ + +#define LogTest(level) ( ldap_debug & (level) ) +#define LogExpand(level, severity, args) \ do { \ if ( ldap_debug & (level) ) \ - lutil_debug( ldap_debug, (level), (fmt), (arg1), (arg2), (arg3), (arg4), (arg5) ); \ + lutil_debug( ldap_debug, (level), args ); \ } 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 Log0( level, severity, fmt ) -#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 ) +#define LogExpand(level, severity, args) ((void) 0) + #endif /* ! LDAP_DEBUG */ +#define LogArg , +#define Log0(level, severity, fmt) \ + LogExpand((level), (severity), (fmt)) +#define Log1(level, severity, fmt, a1) \ + LogExpand((level), (severity), (fmt) LogArg(a1)) +#define Log2(level, severity, fmt, a1, a2) \ + LogExpand((level), (severity), (fmt) LogArg(a1) LogArg(a2)) +#define Log3(level, severity, fmt, a1, a2, a3) \ + LogExpand((level), (severity), (fmt) LogArg(a1) LogArg(a2) LogArg(a3)) +#define Log4(level, severity, fmt, a1, a2, a3, a4) \ + LogExpand((level), (severity), (fmt) LogArg(a1) LogArg(a2) LogArg(a3) \ + LogArg(a4)) +#define Log5(level, severity, fmt, a1, a2, a3, a4, a5) \ + LogExpand((level), (severity), (fmt) LogArg(a1) LogArg(a2) LogArg(a3) \ + LogArg(a4) LogArg(a5)) +#define Debug(level, fmt, a1, a2, a3) \ + LogExpand((level), ldap_syslog_level, (fmt) \ + LogArg(a1) LogArg(a2) LogArg(a3)) + +/* Actually now in liblber/debug.c */ LDAP_LUTIL_F(int) lutil_debug_file LDAP_P(( FILE *file )); LDAP_LUTIL_F(void) lutil_debug LDAP_P(( int debug, int level, const char* fmt, ... )) LDAP_GCCATTR((format(printf, 3, 4))); +#ifdef LDAP_DEFINE_LDAP_DEBUG +/* This struct matches the head of ldapoptions in */ +struct ldapoptions_prefix { + short ldo_valid; + int ldo_debug; +}; +#define ldap_debug \ + (*(int *) ((char *)&ldap_int_global_options \ + + offsetof(struct ldapoptions_prefix, ldo_debug))) + +struct ldapoptions; +LDAP_V ( struct ldapoptions ) ldap_int_global_options; +#endif /* LDAP_DEFINE_LDAP_DEBUG */ + LDAP_END_DECL #endif /* LDAP_LOG_H */