]> arthur.barton.de Git - ngircd-alex.git/blobdiff - src/ngircd/log.c
Write "error file" (/tmp/ngircd-XXX.err) only if compiled with debug
[ngircd-alex.git] / src / ngircd / log.c
index 6fa7a4a7fbd05abaa8c026a051f7a5000e5cd489..153ffedd9c48fa238e49ca5f34b4bd896b9c1fbd 100644 (file)
@@ -14,7 +14,7 @@
 
 #include "portab.h"
 
-static char UNUSED id[] = "$Id: log.c,v 1.48 2004/10/20 13:47:32 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>
@@ -44,9 +44,12 @@ static char UNUSED id[] = "$Id: log.c,v 1.48 2004/10/20 13:47:32 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 ));
 
@@ -60,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 )
@@ -90,10 +92,14 @@ 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 )
 {
@@ -113,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 )
@@ -128,11 +136,13 @@ Log_Exit( VOID )
        if( NGIRCd_SignalRestart ) Log( LOG_NOTICE, "%s done (restarting).", PACKAGE_NAME );
        else Log( LOG_NOTICE, "%s done.", PACKAGE_NAME );
 
+#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 */
@@ -199,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 );
        }
@@ -273,7 +283,7 @@ va_dcl
                fflush( stdout );
        }
 #ifdef SYSLOG
-       else syslog( Level, msg );
+       else syslog( Level, "%s", msg );
 #endif
 } /* Log_Resolver */