SICS-777 Allow the log directory to be set by SICS_INIT_LOGPATH environement variable
This commit is contained in:
16
servlog.c
16
servlog.c
@ -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;
|
||||
|
Reference in New Issue
Block a user