[Date Prev][Date Next] [Chronological] [Thread] [Top]

(ITS#4553) ldap_dump_connection does not use Debug() macro but writes to stderr directly

Full_Name: Christian Geist
Version: 2.3.20
OS: Aix, Hpux, SunOS, Linux, Windows
URL: ftp://ftp.openldap.org/incoming/
Submission from: (NULL) (

I use the following code to trap debug output of OpenLDAP's client libraries: 
  if ( (*pLdapFvt->SCber_set_option)( NULL, LBER_OPT_LOG_PRINT_FN, (void
*)&ldap_ber_error_print ) != LBER_OPT_SUCCESS )
    log_print( "LDAP: Could not set LBER_OPT_LOG_PRINT_FN" );
    log_print( "LDAP: Succesfully set LBER_OPT_LOG_PRINT_FN" );

ldap_ber_error_print() is a function of my own which redirects OpenLDAP messages
into a log file and prefixes them with pid and timestamp and such.

The ldap client libraries are build with LDAP_DEBUG. My problem is that the
function ldap_dump_connection() in libraries/libldap/request.c writes directly
to stderr using fprintf and therefore the output gets lost. Or if I redirect
stderr into my log file using freopen, it will not get prefixed, and since the
log file is shared among multiple processes and threads, I cannot tell which
process or thread generated the output.

Calls to fprintf( stderr, ... )
	fprintf( stderr, "** ld %p Connection%s:\n", (void *)ld, all ? "s" : "" );
should be replaced by Debug() macros:
	Debug( LDAP_DEBUG_TRACE, "** ld %p Connection%s:\n", (void *)ld, all ? "s" :
"", 0 );