mirror of
https://git.openldap.org/openldap/openldap.git
synced 2025-02-23 14:09:39 +08:00
Check debug level before invoking debug routine, slight optimization
This commit is contained in:
parent
c0c9c47032
commit
2f6b7e3d43
@ -111,14 +111,18 @@ LDAP_BEGIN_DECL
|
||||
# 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
|
||||
|
@ -16,7 +16,7 @@
|
||||
|
||||
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;
|
||||
|
||||
@ -102,11 +102,6 @@ int ber_pvt_log_output( char *subsystem, int level, const char *fmt, ... )
|
||||
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 ];
|
||||
|
@ -819,17 +819,20 @@ sb_debug_read( Sockbuf_IO_Desc *sbiod, void *buf, ber_len_t len )
|
||||
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;
|
||||
}
|
||||
@ -840,18 +843,21 @@ sb_debug_write( Sockbuf_IO_Desc *sbiod, void *buf, ber_len_t len )
|
||||
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;
|
||||
|
Loading…
Reference in New Issue
Block a user