Added LDAP_LOG messages

This commit is contained in:
Julius Enarusai 2002-04-15 17:57:44 +00:00
parent a9b521cef4
commit c7d183a19b
2 changed files with 62 additions and 0 deletions

View file

@ -63,8 +63,13 @@ slurpd_read_config(
int cargc; int cargc;
char *cargv[MAXARGS]; char *cargv[MAXARGS];
#ifdef NEW_LOGGING
LDAP_LOG (( "config", LDAP_LEVEL_ARGS,
"slurpd_read_config: Config: opening config file \"%s\"\n", fname ));
#else
Debug( LDAP_DEBUG_CONFIG, "Config: opening config file \"%s\"\n", Debug( LDAP_DEBUG_CONFIG, "Config: opening config file \"%s\"\n",
fname, 0, 0 ); fname, 0, 0 );
#endif
if ( (fp = fopen( fname, "r" )) == NULL ) { if ( (fp = fopen( fname, "r" )) == NULL ) {
perror( fname ); perror( fname );
@ -78,7 +83,12 @@ slurpd_read_config(
continue; continue;
} }
#ifdef NEW_LOGGING
LDAP_LOG (( "config", LDAP_LEVEL_DETAIL1,
"slurpd_read_config: Config: (%s)\n", line ));
#else
Debug( LDAP_DEBUG_CONFIG, "Config: (%s)\n", line, 0, 0 ); Debug( LDAP_DEBUG_CONFIG, "Config: (%s)\n", line, 0, 0 );
#endif
parse_line( line, &cargc, cargv ); parse_line( line, &cargc, cargv );
@ -142,9 +152,15 @@ slurpd_read_config(
} }
} }
fclose( fp ); fclose( fp );
#ifdef NEW_LOGGING
LDAP_LOG (( "config", LDAP_LEVEL_RESULTS,
"slurpd_read_config: Config: "
"** configuration file successfully read and parsed\n" ));
#else
Debug( LDAP_DEBUG_CONFIG, Debug( LDAP_DEBUG_CONFIG,
"Config: ** configuration file successfully read and parsed\n", "Config: ** configuration file successfully read and parsed\n",
0, 0, 0 ); 0, 0, 0 );
#endif
return 0; return 0;
} }
@ -313,11 +329,19 @@ add_replica(
sglob->replicas[ nr - 1] = NULL; sglob->replicas[ nr - 1] = NULL;
sglob->num_replicas--; sglob->num_replicas--;
} else { } else {
#ifdef NEW_LOGGING
LDAP_LOG (( "config", LDAP_LEVEL_RESULTS,
"add_replica: Config: ** successfully added replica \"%s%d\"\n",
sglob->replicas[ nr - 1 ]->ri_hostname == NULL ?
"(null)" : sglob->replicas[ nr - 1 ]->ri_hostname,
sglob->replicas[ nr - 1 ]->ri_port, 0 ));
#else
Debug( LDAP_DEBUG_CONFIG, Debug( LDAP_DEBUG_CONFIG,
"Config: ** successfully added replica \"%s:%d\"\n", "Config: ** successfully added replica \"%s:%d\"\n",
sglob->replicas[ nr - 1 ]->ri_hostname == NULL ? sglob->replicas[ nr - 1 ]->ri_hostname == NULL ?
"(null)" : sglob->replicas[ nr - 1 ]->ri_hostname, "(null)" : sglob->replicas[ nr - 1 ]->ri_hostname,
sglob->replicas[ nr - 1 ]->ri_port, 0 ); sglob->replicas[ nr - 1 ]->ri_port, 0 );
#endif
sglob->replicas[ nr - 1]->ri_stel = sglob->replicas[ nr - 1]->ri_stel =
sglob->st->st_add( sglob->st, sglob->st->st_add( sglob->st,
sglob->replicas[ nr - 1 ] ); sglob->replicas[ nr - 1 ] );

View file

@ -91,16 +91,26 @@ fm(
while ( !sglob->slurpd_shutdown ) { while ( !sglob->slurpd_shutdown ) {
if ( file_nonempty( sglob->slapd_replogfile )) { if ( file_nonempty( sglob->slapd_replogfile )) {
/* New work found - copy to slurpd replog file */ /* New work found - copy to slurpd replog file */
#ifdef NEW_LOGGING
LDAP_LOG (( "fm", LDAP_LEVEL_ARGS,
"fm: new work in %s\n", sglob->slapd_replogfile ));
#else
Debug( LDAP_DEBUG_ARGS, "new work in %s\n", Debug( LDAP_DEBUG_ARGS, "new work in %s\n",
sglob->slapd_replogfile, 0, 0 ); sglob->slapd_replogfile, 0, 0 );
#endif
if (( rc = copy_replog( sglob->slapd_replogfile, if (( rc = copy_replog( sglob->slapd_replogfile,
sglob->slurpd_replogfile )) == 0 ) { sglob->slurpd_replogfile )) == 0 ) {
populate_queue( sglob->slurpd_replogfile ); populate_queue( sglob->slurpd_replogfile );
} else { } else {
if ( rc < 0 ) { if ( rc < 0 ) {
#ifdef NEW_LOGGING
LDAP_LOG (( "fm", LDAP_LEVEL_CRIT,
"fm: Fatal error while copying replication log\n" ));
#else
Debug( LDAP_DEBUG_ANY, Debug( LDAP_DEBUG_ANY,
"Fatal error while copying replication log\n", "Fatal error while copying replication log\n",
0, 0, 0 ); 0, 0, 0 );
#endif
sglob->slurpd_shutdown = 1; sglob->slurpd_shutdown = 1;
} }
} }
@ -116,16 +126,26 @@ fm(
FILE *fp, *lfp; FILE *fp, *lfp;
if (( rc = acquire_lock( sglob->slurpd_replogfile, &fp, if (( rc = acquire_lock( sglob->slurpd_replogfile, &fp,
&lfp )) < 0 ) { &lfp )) < 0 ) {
#ifdef NEW_LOGGING
LDAP_LOG (( "fm", LDAP_LEVEL_ERR,
"fm: Error: cannot acquire lock on \"%s\" for trimming\n",
sglob->slurpd_replogfile ));
#else
Debug( LDAP_DEBUG_ANY, Debug( LDAP_DEBUG_ANY,
"Error: cannot acquire lock on \"%s\" for trimming\n", "Error: cannot acquire lock on \"%s\" for trimming\n",
sglob->slurpd_replogfile, 0, 0 ); sglob->slurpd_replogfile, 0, 0 );
#endif
} else { } else {
sglob->rq->rq_write( sglob->rq, fp ); sglob->rq->rq_write( sglob->rq, fp );
(void) relinquish_lock( sglob->slurpd_replogfile, fp, lfp ); (void) relinquish_lock( sglob->slurpd_replogfile, fp, lfp );
} }
} }
} }
#ifdef NEW_LOGGING
LDAP_LOG (( "fm", LDAP_LEVEL_RESULTS, "fm: exiting\n" ));
#else
Debug( LDAP_DEBUG_ARGS, "fm: exiting\n", 0, 0, 0 ); Debug( LDAP_DEBUG_ARGS, "fm: exiting\n", 0, 0, 0 );
#endif
return NULL; return NULL;
} }
@ -179,9 +199,15 @@ populate_queue(
char *p; char *p;
if ( acquire_lock( f, &fp, &lfp ) < 0 ) { if ( acquire_lock( f, &fp, &lfp ) < 0 ) {
#ifdef NEW_LOGGING
LDAP_LOG (( "fm", LDAP_LEVEL_ERR,
"populate_queue: error: can't lock file \"%s\": %s\n",
f, sys_errlist[ errno ] ));
#else
Debug( LDAP_DEBUG_ANY, Debug( LDAP_DEBUG_ANY,
"error: can't lock file \"%s\": %s\n", "error: can't lock file \"%s\": %s\n",
f, sys_errlist[ errno ], 0 ); f, sys_errlist[ errno ], 0 );
#endif
return; return;
} }
@ -190,9 +216,15 @@ populate_queue(
* the queue. * the queue.
*/ */
if ( fseek( fp, sglob->srpos, 0 ) < 0 ) { if ( fseek( fp, sglob->srpos, 0 ) < 0 ) {
#ifdef NEW_LOGGING
LDAP_LOG (( "fm", LDAP_LEVEL_ERR,
"populate_queue: error: can't seek to offset %ld in file \"%s\"\n",
sglob->srpos, f ));
#else
Debug( LDAP_DEBUG_ANY, Debug( LDAP_DEBUG_ANY,
"error: can't seek to offset %ld in file \"%s\"\n", "error: can't seek to offset %ld in file \"%s\"\n",
sglob->srpos, f, 0 ); sglob->srpos, f, 0 );
#endif
} else { } else {
while (( p = get_record( fp )) != NULL ) { while (( p = get_record( fp )) != NULL ) {
if ( sglob->rq->rq_add( sglob->rq, p ) < 0 ) { if ( sglob->rq->rq_add( sglob->rq, p ) < 0 ) {
@ -201,9 +233,15 @@ populate_queue(
if (( t = strchr( p, '\n' )) != NULL ) { if (( t = strchr( p, '\n' )) != NULL ) {
*t = '\0'; *t = '\0';
} }
#ifdef NEW_LOGGING
LDAP_LOG (( "fm", LDAP_LEVEL_ERR,
"populate_queue: error: malformed replog entry "
"(begins with \"%s\")\n", p ));
#else
Debug( LDAP_DEBUG_ANY, Debug( LDAP_DEBUG_ANY,
"error: malformed replog entry (begins with \"%s\")\n", "error: malformed replog entry (begins with \"%s\")\n",
p, 0, 0 ); p, 0, 0 );
#endif
} }
free( p ); free( p );
ldap_pvt_thread_yield(); ldap_pvt_thread_yield();