# ifdef LDAP_SYSLOG
# define Debug( level, fmt, arg1, arg2, arg3 ) \
do { \
- lutil_debug( ldap_debug, (level), (fmt), (arg1), (arg2), (arg3) ); \
+ 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) ); \
} while ( 0 )
# else
# define Debug( level, fmt, arg1, arg2, arg3 ) \
- lutil_debug( ldap_debug, (level), (fmt), (arg1), (arg2), (arg3) )
+ do { \
+ if ( ldap_debug & (level) ) \
+ lutil_debug( ldap_debug, (level), (fmt), (arg1), (arg2), (arg3) ); \
+ } while ( 0 )
# endif
#ifndef LDAP_LOG
typedef void (*BER_LOG_FN) LDAP_P((FILE *file, char *subsys, int level, const char *fmt, va_list vl));
-static int ber_log_check( int errlvl, int loglvl );
+#define ber_log_check(errlvl, loglvl) (errlvl & loglvl)
BER_LOG_FN ber_int_log_proc = NULL;
return 1;
}
-static int ber_log_check( int errlvl, int loglvl )
-{
- return errlvl & loglvl ? 1 : 0;
-}
-
int ber_pvt_log_printf( int errlvl, int loglvl, const char *fmt, ... )
{
char buf[ 1024 ];
ber_slen_t ret;
ret = LBER_SBIOD_READ_NEXT( sbiod, buf, len );
- if ( ret < 0 ) {
+ if (sbiod->sbiod_sb->sb_debug & LDAP_DEBUG_PACKETS)
+ {
+ if ( ret < 0 ) {
ber_log_printf( LDAP_DEBUG_PACKETS, sbiod->sbiod_sb->sb_debug,
"%sread: want=%ld error=%s\n", (char *)sbiod->sbiod_pvt,
(long)len, STRERROR( errno ) );
- } else {
+ } else {
ber_log_printf( LDAP_DEBUG_PACKETS, sbiod->sbiod_sb->sb_debug,
"%sread: want=%ld, got=%ld\n", (char *)sbiod->sbiod_pvt,
(long)len, (long)ret );
ber_log_bprint( LDAP_DEBUG_PACKETS, sbiod->sbiod_sb->sb_debug,
(const char *)buf, ret );
+ }
}
return ret;
}
ber_slen_t ret;
ret = LBER_SBIOD_WRITE_NEXT( sbiod, buf, len );
- if ( ret < 0 ) {
+ if (sbiod->sbiod_sb->sb_debug & LDAP_DEBUG_PACKETS)
+ {
+ if ( ret < 0 ) {
ber_log_printf( LDAP_DEBUG_PACKETS, sbiod->sbiod_sb->sb_debug,
"%swrite: want=%ld error=%s\n",
(char *)sbiod->sbiod_pvt, (long)len,
STRERROR( errno ) );
- } else {
+ } else {
ber_log_printf( LDAP_DEBUG_PACKETS, sbiod->sbiod_sb->sb_debug,
"%swrite: want=%ld, written=%ld\n",
(char *)sbiod->sbiod_pvt, (long)len, (long)ret );
ber_log_bprint( LDAP_DEBUG_PACKETS, sbiod->sbiod_sb->sb_debug,
(const char *)buf, ret );
+ }
}
return ret;