From 1931f7bb627ebca23d8c7dadfcfc972b5bcc3945 Mon Sep 17 00:00:00 2001 From: rswindell <> Date: Tue, 31 May 2016 02:01:55 +0000 Subject: [PATCH] Sysop can over-ride the time-stamp format in the sbbsecho.log by setting the LogTimeFormat key in sbbsecho.ini. The default is "%Y-%m-%d %H:%M:%S". If you want the old (v2) time-stamp format, set this value to "%m/%d/%y %H:%M:%S". Any/all valid strftime() specifiers may be used. --- src/sbbs3/rechocfg.c | 3 +++ src/sbbs3/sbbsecho.c | 10 ++++++---- src/sbbs3/sbbsecho.h | 1 + 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/src/sbbs3/rechocfg.c b/src/sbbs3/rechocfg.c index 5cbe60fc92..195ca2dcab 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 1964783918..3932654124 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 e23a953db5..b16ca2eea3 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 */ -- GitLab