From 1068f883779ad9b8bf3e1e1b8234781e4223761d Mon Sep 17 00:00:00 2001 From: Alexander Barton Date: Fri, 2 Mar 2012 09:41:13 +0100 Subject: [PATCH] Don't log "ngIRCd hello message" two times Start "regular" logging not until the configuration file has been read in and "SyslolgFacility" is set, and log all configuration errors using the generic "daemon" facility. So if there are no configuration errors, logging starts right after parsing the configuration and we log the configuration file used _after_ reading it. But this is no problem because every configuration error message includes the configuration file name as well. (The "double hello" has been introduced by commit 3641e5110952) --- src/ngircd/conf.c | 19 +++++++++++-------- src/ngircd/log.c | 9 ++++++--- 2 files changed, 17 insertions(+), 11 deletions(-) diff --git a/src/ngircd/conf.c b/src/ngircd/conf.c index 58ce9cab..54269009 100644 --- a/src/ngircd/conf.c +++ b/src/ngircd/conf.c @@ -58,7 +58,7 @@ static int New_Server_Idx; static char Conf_MotdFile[FNAME_LEN]; static void Set_Defaults PARAMS(( bool InitServers )); -static bool Read_Config PARAMS(( bool ngircd_starting )); +static bool Read_Config PARAMS(( bool TestOnly, bool IsStarting )); static bool Validate_Config PARAMS(( bool TestOnly, bool Rehash )); static void Handle_GLOBAL PARAMS(( int Line, char *Var, char *Arg )); @@ -206,7 +206,7 @@ ports_parse(array *a, int Line, char *Arg) GLOBAL void Conf_Init( void ) { - Read_Config( true ); + Read_Config(false, true); Validate_Config(false, false); } @@ -218,7 +218,7 @@ Conf_Init( void ) GLOBAL bool Conf_Rehash( void ) { - if (!Read_Config(false)) + if (!Read_Config(false, false)) return false; Validate_Config(false, true); @@ -299,7 +299,7 @@ Conf_Test( void ) Use_Log = false; - if (! Read_Config(true)) + if (!Read_Config(true, true)) return 1; config_valid = Validate_Config(true, false); @@ -778,7 +778,7 @@ Read_Motd(const char *filename) * successfully; false otherwise. */ static bool -Read_Config( bool ngircd_starting ) +Read_Config(bool TestOnly, bool IsStarting) { char section[LINE_LEN], str[LINE_LEN], *var, *arg, *ptr; const UINT16 defaultport = 6667; @@ -792,16 +792,19 @@ Read_Config( bool ngircd_starting ) /* No configuration file found! */ Config_Error( LOG_ALERT, "Can't read configuration \"%s\": %s", NGIRCd_ConfFile, strerror( errno )); - if (!ngircd_starting) + if (!IsStarting) return false; Config_Error( LOG_ALERT, "%s exiting due to fatal errors!", PACKAGE_NAME ); exit( 1 ); } opers_free(); - Set_Defaults( ngircd_starting ); + Set_Defaults(IsStarting); - Config_Error( LOG_INFO, "Reading configuration from \"%s\" ...", NGIRCd_ConfFile ); + if (TestOnly) + Config_Error(LOG_INFO, + "Reading configuration from \"%s\" ...", + NGIRCd_ConfFile ); /* Clean up server configuration structure: mark all already * configured servers as "once" so that they are deleted diff --git a/src/ngircd/log.c b/src/ngircd/log.c index d81bec24..6f0c4c9d 100644 --- a/src/ngircd/log.c +++ b/src/ngircd/log.c @@ -79,10 +79,12 @@ Log_Init(bool Daemon_Mode) #ifndef LOG_CONS /* Kludge: mips-dec-ultrix4.5 has no LOG_CONS */ #define LOG_CONS 0 #endif - openlog(PACKAGE_NAME, LOG_CONS|LOG_PID, Conf_SyslogFacility); +#ifdef LOG_DAEMON + openlog(PACKAGE_NAME, LOG_CONS|LOG_PID, LOG_DAEMON); +#else + openlog(PACKAGE_NAME, LOG_CONS|LOG_PID, 0); +#endif #endif - - Log(LOG_NOTICE, "%s started.", NGIRCd_Version); } /* Log_Init */ @@ -100,6 +102,7 @@ Log_ReInit(void) openlog(PACKAGE_NAME, LOG_CONS|LOG_PID, Conf_SyslogFacility); #endif Log(LOG_NOTICE, "%s started.", NGIRCd_Version); + Log(LOG_INFO, "Using configuration file \"%s\" ...", NGIRCd_ConfFile); } -- 2.39.2