From 1679e9fe29874f23634248fd654a0d766b012563 Mon Sep 17 00:00:00 2001 From: Jing Chen Date: Mon, 15 Feb 2010 12:24:12 +1100 Subject: [PATCH] Add timestamp info to the server00.log file name -> server00_hh:mm:sec-daymonyear r2885 | jgn | 2010-02-15 12:24:12 +1100 (Mon, 15 Feb 2010) | 2 lines --- servlog.c | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/servlog.c b/servlog.c index 64375adf..15b4919e 100644 --- a/servlog.c +++ b/servlog.c @@ -268,7 +268,26 @@ static const char* timestamp(struct timeval *tp) { { strncpy(pFile,pChar,255); } - snprintf(filnam,511,"%s%2.2d.log",pFile, iFile); + + // Jing added here to add timestamp info for the server00.log file name as server00_hh:mm:sec-daymonyear.log + if(iFile==0){ + int hh, mm, ss, day, mon, year; + struct timeval tv; + struct tm *time; + + gettimeofday(&tv, NULL); + time = localtime(&tv.tv_sec); + hh = time->tm_hour; + mm = time->tm_min; + ss = time->tm_sec; + day = time->tm_mday; + mon = time->tm_mon; + year = time->tm_year + 1900; + + snprintf(filnam,511,"%s%2.2d_%02d:%02d:%02d-%02d%02d%04d.log",pFile, iFile, hh, mm, ss, day, mon, year); + }else + snprintf(filnam,511,"%s%2.2d.log",pFile, iFile); + fLogFile = fopen(filnam,"w"); if(!fLogFile) {