SICS-777 Allow the log directory to be set by SICS_INIT_LOGPATH environement variable

This commit is contained in:
Douglas Clowes
2014-09-12 10:41:22 +10:00
parent e8ec81ad5d
commit c93b4d30a3

View File

@ -270,8 +270,8 @@ static FILE *fLogFile = NULL;
static int iFile = 0;
static int iLineCount = 0;
static int iLogUsable = 1;
static char filnam[512];
static char prevfilnam[512];
static char filnam[1024];
static char prevfilnam[1024];
/*---------------------------------------------------------------------------*/
int OpenVerifyLogFile()
@ -280,17 +280,21 @@ int OpenVerifyLogFile()
char *pChar = NULL;
char fPath[1024];
/* snprintf(fPath, 1023, "%s/", getenv("SICS_INIT_LOGPATH")); */
snprintf(fPath, 1023, "%s/", "../log");
pChar = getenv("SICS_INIT_LOGPATH");
if (!pChar) {
snprintf(fPath, sizeof(fPath) - 1, "%s/", "../log");
} else {
snprintf(fPath, sizeof(fPath) - 1, "%s/", pChar);
}
pChar = IFindOption(pSICSOptions, "LogFileBaseName");
if (!pChar) { /* Try to write to file "server" in */
strcpy(pFile, "server");
} else {
strlcpy(pFile, pChar, 255);
strlcpy(pFile, pChar, sizeof(pFile) - 1);
}
snprintf(filnam, 511, "%s%s_%19.19s.%02d.log", fPath, pFile, timestamp(NULL, '-'), iFile);
snprintf(filnam, sizeof(filnam) - 1, "%s%s_%19.19s.%02d.log", fPath, pFile, timestamp(NULL, '-'), iFile);
iFile++;
if (iFile >= MAXFILES) {
iFile = 0;