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
This commit is contained in:
committed by
Douglas Clowes
parent
4f3fb5e250
commit
1679e9fe29
19
servlog.c
19
servlog.c
@@ -268,7 +268,26 @@ static const char* timestamp(struct timeval *tp) {
|
|||||||
{
|
{
|
||||||
strncpy(pFile,pChar,255);
|
strncpy(pFile,pChar,255);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 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);
|
snprintf(filnam,511,"%s%2.2d.log",pFile, iFile);
|
||||||
|
|
||||||
fLogFile = fopen(filnam,"w");
|
fLogFile = fopen(filnam,"w");
|
||||||
if(!fLogFile)
|
if(!fLogFile)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user