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

logging enhancements, take 2

Here's what I have for libldap:

The following is added to print.c.  Similar changes would be made in modules
for the other libraries (liblber, libavl, etc.)  A static variable holding the
address of an external logging routine, and functions that can set and get the
address.  The debugging macro would then check the external function and use it
if it's been set, otherwise use the existing logging routine.

static void (*ldap_logProc) LDAP_P(( char *subsys, int level, char *fmt, ... ));

 * ldap log 

void ldap_setLogProc( void (*logProc) LDAP_P(( char *subsys, int level, char *fmt, ... )) )
	ldap_logProc = logProc;

void* ldap_getLogProc()
	return (void*)ldap_logProc;

This is from ldap-int.h

#define LDAP_Debug( subsystem, level, fmt, arg1, arg2, arg3 )\
   if ( ldap_getLogProc() != NULL ) \
       void (*ld_debug_function)(char*,int,char*,...) = ldap_getLogProc(); \
	   (ld_debug_function)(subsystem, level, fmt, arg1, arg2, arg3 );\
   else Debug( level, fmt, arg1, arg2, arg3 );

If this is acceptable, I'll proceed putting it in all the libraries and updating the
configuration routines and command lines to accept logging configuration.  If it's
not acceptable we can continue the discussion.

Gary D. Williams 
Sr. System Developer, Distributed Technologies
919-677-8000 x4059

SAS... The Power to Know