#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 <assert.h>
#include <errno.h>
-#include <stdarg.h>
+#ifdef PROTOTYPES
+# include <stdarg.h>
+#else
+# include <varargs.h>
+#endif
#include <stdio.h>
#include <string.h>
#include <sys/types.h>
#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 ));
#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 )
}
#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 )
{
/* 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 )
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 */
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
if( Level <= LOG_CRIT )
{
- /* Kritische Meldungen in Error-File (stderr) */
+ /* log critical messages to stderr */
fprintf( stderr, "%s\n", msg );
fflush( stderr );
}
#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
{
/* 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
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 */