X-Git-Url: https://arthur.barton.de/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Fngircd%2Flog.c;h=153ffedd9c48fa238e49ca5f34b4bd896b9c1fbd;hb=1d08d51e2eaff14b71f20d3f0898d5a86582b7e5;hp=1c8d2c7b3e1b52ab37b6b14cb88568d63d434212;hpb=c40592d2cef21dd255af978644eb96c330913be7;p=ngircd-alex.git diff --git a/src/ngircd/log.c b/src/ngircd/log.c index 1c8d2c7b..153ffedd 100644 --- a/src/ngircd/log.c +++ b/src/ngircd/log.c @@ -14,12 +14,16 @@ #include "portab.h" -static char UNUSED id[] = "$Id: log.c,v 1.44 2003/12/26 15:55:07 alex Exp $"; +static char UNUSED id[] = "$Id: log.c,v 1.52 2005/02/10 12:49:04 alex Exp $"; #include "imp.h" #include #include -#include +#ifdef PROTOTYPES +# include +#else +# include +#endif #include #include #include @@ -40,9 +44,12 @@ static char UNUSED id[] = "$Id: log.c,v 1.44 2003/12/26 15:55:07 alex Exp $"; #include "log.h" -LOCAL CHAR Error_File[FNAME_LEN]; LOCAL CHAR Init_Txt[127]; +#ifdef DEBUG +LOCAL CHAR Error_File[FNAME_LEN]; +#endif + LOCAL VOID Wall_ServerNotice PARAMS(( CHAR *Msg )); @@ -56,15 +63,14 @@ Log_Init( VOID ) #endif /* Hello World! */ - Log( LOG_NOTICE, "%s started.", NGIRCd_Version( )); + Log( LOG_NOTICE, "%s started.", NGIRCd_Version ); /* Informationen uebern den "Operation Mode" */ - strcpy( Init_Txt, "" ); + Init_Txt[0] = '\0'; #ifdef DEBUG if( NGIRCd_Debug ) { - if( Init_Txt[0] ) strcat( Init_Txt, ", " ); - strcat( Init_Txt, "debug-mode" ); + strcpy( Init_Txt, "debug-mode" ); } #endif if( NGIRCd_NoDaemon ) @@ -85,9 +91,15 @@ Log_Init( VOID ) } #endif if( Init_Txt[0] ) Log( LOG_INFO, "Activating: %s.", Init_Txt ); + +#ifdef DEBUG + Error_File[0] = '\0'; +#endif } /* Log_Init */ +#ifdef DEBUG + GLOBAL VOID Log_InitErrorfile( VOID ) { @@ -107,13 +119,15 @@ Log_InitErrorfile( VOID ) /* Einige Infos in das Error-File schreiben */ fputs( ctime( &NGIRCd_Start ), stderr ); - fprintf( stderr, "%s started.\n", NGIRCd_Version( )); + fprintf( stderr, "%s started.\n", NGIRCd_Version ); fprintf( stderr, "Activating: %s\n\n", Init_Txt[0] ? Init_Txt : "-" ); fflush( stderr ); Log( LOG_DEBUG, "Redirected stderr to \"%s\".", Error_File ); } /* Log_InitErrfile */ +#endif + GLOBAL VOID Log_Exit( VOID ) @@ -122,8 +136,13 @@ Log_Exit( VOID ) if( NGIRCd_SignalRestart ) Log( LOG_NOTICE, "%s done (restarting).", PACKAGE_NAME ); else Log( LOG_NOTICE, "%s done.", PACKAGE_NAME ); - /* Error-File (stderr) loeschen */ - if( unlink( Error_File ) != 0 ) Log( LOG_ERR, "Can't delete \"%s\": %s", Error_File, strerror( errno )); +#ifdef DEBUG + if( Error_File[0] ) + { + /* Error-File (stderr) loeschen */ + if( unlink( Error_File ) != 0 ) Log( LOG_ERR, "Can't delete \"%s\": %s", Error_File, strerror( errno )); + } +#endif #ifdef SYSLOG /* syslog abmelden */ @@ -177,7 +196,7 @@ va_dcl if( NGIRCd_NoDaemon ) { /* auf Konsole ausgeben */ - fprintf( stdout, "[%d] %s\n", Level, msg ); + fprintf( stdout, "[%d:%d] %s\n", (INT)getpid( ), Level, msg ); fflush( stdout ); } #ifdef SYSLOG @@ -190,7 +209,7 @@ va_dcl if( Level <= LOG_CRIT ) { - /* Kritische Meldungen in Error-File (stderr) */ + /* log critical messages to stderr */ fprintf( stderr, "%s\n", msg ); fflush( stderr ); } @@ -209,12 +228,14 @@ Log_Init_Resolver( VOID ) #ifdef SYSLOG openlog( PACKAGE_NAME, LOG_CONS|LOG_PID, LOG_LOCAL5 ); #endif + Log_Resolver( LOG_DEBUG, "Resolver sub-process starting, PID %d.", getpid( )); } /* Log_Init_Resolver */ GLOBAL VOID Log_Exit_Resolver( VOID ) { + Log_Resolver( LOG_DEBUG, "Resolver sub-process %d done.", getpid( )); #ifdef SYSLOG closelog( ); #endif @@ -234,17 +255,11 @@ va_dcl { /* Eintrag des Resolver in Logfile(s) schreiben */ -#ifndef SYSLOG - return; -#else - CHAR msg[MAX_LOG_MSG_LEN]; va_list ap; assert( Format != NULL ); - if( NGIRCd_NoDaemon ) return; - #ifdef DEBUG if(( Level == LOG_DEBUG ) && ( ! NGIRCd_Debug )) return; #else @@ -260,9 +275,15 @@ va_dcl vsnprintf( msg, MAX_LOG_MSG_LEN, Format, ap ); va_end( ap ); - /* ... und ausgeben */ - syslog( Level, msg ); - + /* Output */ + if( NGIRCd_NoDaemon ) + { + /* Output to console */ + fprintf( stdout, "[%d:%d] %s\n", (INT)getpid( ), Level, msg ); + fflush( stdout ); + } +#ifdef SYSLOG + else syslog( Level, "%s", msg ); #endif } /* Log_Resolver */