commit 1068f883779ad9b8bf3e1e1b8234781e4223761d from: Alexander Barton date: Fri Mar 02 08:41:13 2012 UTC 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) commit - 9e7360e5faea1468f0906f993c965b8b085ee46a commit + 1068f883779ad9b8bf3e1e1b8234781e4223761d blob - 58ce9cab99fd14277842b2c85286d231ff99d370 blob + 54269009d1ee433bb537fa1c4ef140f34ea2cb57 --- src/ngircd/conf.c +++ 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 blob - d81bec2496a8c966b1771926564f26bcf404a2a8 blob + 6f0c4c9db1129d3a2cc291d6d3811fd297591ebb --- src/ngircd/log.c +++ 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 - - Log(LOG_NOTICE, "%s started.", NGIRCd_Version); +#endif } /* 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); }