Back to index

openldap  2.4.31
Functions | Variables
debug.c File Reference
#include "portable.h"
#include <stdio.h>
#include <ac/stdarg.h>
#include <ac/stdlib.h>
#include <ac/string.h>
#include <ac/time.h>
#include <ac/ctype.h>
#include "ldap_log.h"
#include "ldap_defaults.h"
#include "lber.h"
#include "ldap_pvt.h"

Go to the source code of this file.

Functions

int lutil_debug_file (FILE *file)
void() lutil_debug (int debug, int level, const char *fmt,...)

Variables

static FILE * log_file = NULL

Function Documentation

void() lutil_debug ( int  debug,
int  level,
const char *  fmt,
  ... 
)

Definition at line 45 of file debug.c.

{
       char buffer[4096];
       va_list vl;

       if ( !(level & debug ) ) return;

#ifdef HAVE_WINSOCK
       if( log_file == NULL ) {
              log_file = fopen( LDAP_RUNDIR LDAP_DIRSEP "openldap.log", "w" );

              if ( log_file == NULL ) {
                     log_file = fopen( "openldap.log", "w" );
                     if ( log_file == NULL ) return;
              }

              ber_set_option( NULL, LBER_OPT_LOG_PRINT_FILE, log_file );
       }
#endif

       sprintf(buffer, "%08x ", (unsigned) time(0L));
       va_start( vl, fmt );
       vsnprintf( buffer+9, sizeof(buffer)-9, fmt, vl );
       buffer[sizeof(buffer)-1] = '\0';
       if( log_file != NULL ) {
              fputs( buffer, log_file );
              fflush( log_file );
       }
       fputs( buffer, stderr );
       va_end( vl );
}

Here is the call graph for this function:

int lutil_debug_file ( FILE *  file)

Definition at line 37 of file debug.c.

{
       log_file = file;
       ber_set_option( NULL, LBER_OPT_LOG_PRINT_FILE, file );

       return 0;
}

Here is the call graph for this function:

Here is the caller graph for this function:


Variable Documentation

FILE* log_file = NULL [static]

Definition at line 35 of file debug.c.