diff --git a/src/sbbs3/rechocfg.c b/src/sbbs3/rechocfg.c index 5cbe60fc923f08536090a99c74e7eb01f25b61a6..195ca2dcab03ee450271cf5320aa6d55175d6c27 100644 --- a/src/sbbs3/rechocfg.c +++ b/src/sbbs3/rechocfg.c @@ -247,6 +247,7 @@ bool sbbsecho_read_ini(sbbsecho_cfg_t* cfg) SAFECOPY(cfg->outbound , iniGetString(ini, ROOT_SECTION, "Outbound", "../fido/outbound", value)); SAFECOPY(cfg->areafile , iniGetString(ini, ROOT_SECTION, "AreaFile", "../data/areas.bbs", value)); SAFECOPY(cfg->logfile , iniGetString(ini, ROOT_SECTION, "LogFile", "../data/sbbsecho.log", value)); + SAFECOPY(cfg->logtime , iniGetString(ini, ROOT_SECTION, "LogTimeFormat", "%Y-%m-%d %H:%M:%S", value)); SAFECOPY(cfg->temp_dir , iniGetString(ini, ROOT_SECTION, "TempDirectory", "../temp/sbbsecho", value)); SAFECOPY(cfg->outgoing_sem , iniGetString(ini, ROOT_SECTION, "OutgoingSemaphore", "", value)); cfg->log_level = iniGetLogLevel(ini, ROOT_SECTION, "LogLevel", cfg->log_level); @@ -446,6 +447,8 @@ bool sbbsecho_write_ini(sbbsecho_cfg_t* cfg) iniSetString(&ini, ROOT_SECTION, "AreaFile" ,cfg->areafile ,NULL); if(cfg->logfile[0]) iniSetString(&ini, ROOT_SECTION, "LogFile" ,cfg->logfile ,NULL); + if(cfg->logtime[0]) + iniSetString(&ini, ROOT_SECTION, "LogTimeFormat" ,cfg->logtime ,NULL); if(cfg->temp_dir[0]) iniSetString(&ini, ROOT_SECTION, "TempDirectory" ,cfg->temp_dir ,NULL); iniSetBytes(&ini, ROOT_SECTION, "BundleSize" ,1,cfg->maxbdlsize ,NULL); diff --git a/src/sbbs3/sbbsecho.c b/src/sbbs3/sbbsecho.c index 1964783918bfa0bcbbf8b5f2c0687c700faffdbe..39326541240b4f8a6f2215b5444a35fc6347df50 100644 --- a/src/sbbs3/sbbsecho.c +++ b/src/sbbs3/sbbsecho.c @@ -171,13 +171,15 @@ int lprintf(int level, char *fmt, ...) time_t now = time(NULL); struct tm *tm; struct tm tmbuf = {0}; + char timestamp[128]; strip_ctrl(sbuf, sbuf); if((tm = localtime(&now)) == NULL) tm = &tmbuf; - fprintf(fidologfile,"%u-%02u-%02u %02u:%02u:%02u %s\n" - ,1900+tm->tm_year, tm->tm_mon+1, tm->tm_mday - ,tm->tm_hour, tm->tm_min, tm->tm_sec - ,sbuf); + if(strftime(timestamp, sizeof(timestamp), cfg.logtime, tm) <= 0) + snprintf(timestamp, sizeof(timestamp)-1, "%u-%02u-%02u %02u:%02u:%02u" + ,1900+tm->tm_year, tm->tm_mon+1, tm->tm_mday + ,tm->tm_hour, tm->tm_min, tm->tm_sec); + fprintf(fidologfile, "%s %s\n", timestamp, sbuf); fflush(fidologfile); } return(chcount); diff --git a/src/sbbs3/sbbsecho.h b/src/sbbs3/sbbsecho.h index e23a953db598846e269752190038f6bbf9888871..b16ca2eea33ff6e3f4ec61db0dfedef81c7c6193 100644 --- a/src/sbbs3/sbbsecho.h +++ b/src/sbbs3/sbbsecho.h @@ -134,6 +134,7 @@ typedef struct { char outbound[MAX_PATH+1]; /* Outbound directory */ char areafile[MAX_PATH+1]; /* AREAS.BBS path/filename */ char logfile[MAX_PATH+1]; /* LOG path/filename */ + char logtime[64]; /* format of log timestamp */ char cfgfile[MAX_PATH+1]; /* Configuration path/filename */ char temp_dir[MAX_PATH+1]; /* Temporary file directory */ char outgoing_sem[MAX_PATH+1]; /* Semaphore file to creat when there's outgoing data */