1999-04-02 00:39:36 +08:00
|
|
|
|
1999-05-06 22:47:55 +08:00
|
|
|
#include "portable.h"
|
1999-05-19 09:12:33 +08:00
|
|
|
|
|
|
|
#include <stdio.h>
|
|
|
|
|
|
|
|
#include <ac/stdarg.h>
|
|
|
|
#include <ac/string.h>
|
|
|
|
|
1999-05-06 22:47:55 +08:00
|
|
|
#include "slap.h"
|
1999-06-17 12:43:24 +08:00
|
|
|
#include "ldap_defaults.h"
|
1999-05-06 22:47:55 +08:00
|
|
|
|
1999-04-02 00:39:36 +08:00
|
|
|
static FILE *log_file;
|
|
|
|
|
1999-06-02 11:09:40 +08:00
|
|
|
void (Debug)( int level, const char *fmt, ... )
|
1999-04-02 00:39:36 +08:00
|
|
|
{
|
|
|
|
char buffer[4096];
|
|
|
|
va_list vl;
|
|
|
|
|
1999-05-06 22:47:55 +08:00
|
|
|
if ( !(level & ldap_debug ) )
|
|
|
|
return;
|
|
|
|
|
1999-04-02 00:39:36 +08:00
|
|
|
if( log_file == NULL )
|
1999-05-06 22:47:55 +08:00
|
|
|
{
|
1999-06-17 11:54:25 +08:00
|
|
|
log_file = fopen( LDAP_RUNDIR LDAP_DIRSEP "slapd.log", "w" );
|
1999-04-02 00:39:36 +08:00
|
|
|
|
1999-05-06 22:47:55 +08:00
|
|
|
if ( log_file == NULL )
|
|
|
|
log_file = fopen( "slapd.log", "w" );
|
|
|
|
|
|
|
|
if ( log_file == NULL )
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
1999-04-02 00:39:36 +08:00
|
|
|
va_start( vl, fmt );
|
|
|
|
vsprintf( buffer, fmt, vl );
|
1999-05-06 22:47:55 +08:00
|
|
|
fprintf( log_file, "%s", buffer );
|
|
|
|
|
|
|
|
printf ("%s", buffer);
|
|
|
|
|
1999-04-02 00:39:36 +08:00
|
|
|
fflush( log_file );
|
|
|
|
va_end( vl );
|
|
|
|
}
|