added request amb122

This commit is contained in:
David Anderson 2007-05-03 13:27:51 +00:00
parent 6170cbc95a
commit 3b737ab87b

View File

@ -97,11 +97,13 @@ void CLog::CreateNewFile()
tm *curTime = localtime(&td); tm *curTime = localtime(&td);
char file[256]; char file[256];
char name[256];
int i = 0; int i = 0;
while (true) while (true)
{ {
build_pathname_r(file, sizeof(file)-1, "%s/L%02d%02d%03d.log", g_log_dir.c_str(), curTime->tm_mon + 1, curTime->tm_mday, i); snprintf(name, sizeof(name), "%s/L%02d%02d%03d.log", g_log_dir.c_str(), curTime->tm_mon + 1, curTime->tm_mday, i);
build_pathname_r(file, sizeof(file)-1, "%s", name);
FILE *pTmpFile = fopen(file, "r"); // open for reading to check whether the file exists FILE *pTmpFile = fopen(file, "r"); // open for reading to check whether the file exists
if (!pTmpFile) if (!pTmpFile)
@ -120,7 +122,7 @@ void CLog::CreateNewFile()
ALERT(at_logged, "[AMXX] Unexpected fatal logging error. AMXX Logging disabled.\n"); ALERT(at_logged, "[AMXX] Unexpected fatal logging error. AMXX Logging disabled.\n");
SET_LOCALINFO("amxx_logging", "0"); SET_LOCALINFO("amxx_logging", "0");
} else { } else {
fprintf(fp, "AMX Mod X log file started (file \"%s/L%02d%02d%03d.log\") (version \"%s\")\n", g_log_dir.c_str(), curTime->tm_mon + 1, curTime->tm_mday, i, SVN_VERSION_STRING); fprintf(fp, "AMX Mod X log file started (file \"%s\") (version \"%s\")\n", name, SVN_VERSION_STRING);
fclose(fp); fclose(fp);
} }
} }
@ -202,7 +204,7 @@ void CLog::Log(const char *fmt, ...)
} }
} }
} else { } else {
build_pathname_r(file, sizeof(file)-1, "%s/L%02d%02d.log", g_log_dir.c_str(), curTime->tm_mon + 1, curTime->tm_mday); build_pathname_r(file, sizeof(file)-1, "%s/L%04d%02d%02d.log", g_log_dir.c_str(), (curTime->tm_year + 1900), curTime->tm_mon + 1, curTime->tm_mday);
pF = fopen(file, "a+"); pF = fopen(file, "a+");
} }
@ -255,7 +257,7 @@ void CLog::LogError(const char *fmt, ...)
va_end(arglst); va_end(arglst);
FILE *pF = NULL; FILE *pF = NULL;
build_pathname_r(file, sizeof(file)-1, "%s/error_%02d%02d%02d.log", g_log_dir.c_str(), curTime->tm_mon + 1, curTime->tm_mday, curTime->tm_year - 100); build_pathname_r(file, sizeof(file)-1, "%s/error_%04d%02d%02d.log", g_log_dir.c_str(), (curTime->tm_year + 1900), curTime->tm_mon + 1, curTime->tm_mday);
pF = fopen(file, "a+"); pF = fopen(file, "a+");
if (pF) if (pF)