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 iFile = 0;
|
||||||
static int iLineCount = 0;
|
static int iLineCount = 0;
|
||||||
static int iLogUsable = 1;
|
static int iLogUsable = 1;
|
||||||
static char filnam[512];
|
static char filnam[1024];
|
||||||
static char prevfilnam[512];
|
static char prevfilnam[1024];
|
||||||
|
|
||||||
/*---------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------*/
|
||||||
int OpenVerifyLogFile()
|
int OpenVerifyLogFile()
|
||||||
@ -280,17 +280,21 @@ int OpenVerifyLogFile()
|
|||||||
char *pChar = NULL;
|
char *pChar = NULL;
|
||||||
char fPath[1024];
|
char fPath[1024];
|
||||||
|
|
||||||
/* snprintf(fPath, 1023, "%s/", getenv("SICS_INIT_LOGPATH")); */
|
pChar = getenv("SICS_INIT_LOGPATH");
|
||||||
snprintf(fPath, 1023, "%s/", "../log");
|
if (!pChar) {
|
||||||
|
snprintf(fPath, sizeof(fPath) - 1, "%s/", "../log");
|
||||||
|
} else {
|
||||||
|
snprintf(fPath, sizeof(fPath) - 1, "%s/", pChar);
|
||||||
|
}
|
||||||
|
|
||||||
pChar = IFindOption(pSICSOptions, "LogFileBaseName");
|
pChar = IFindOption(pSICSOptions, "LogFileBaseName");
|
||||||
if (!pChar) { /* Try to write to file "server" in */
|
if (!pChar) { /* Try to write to file "server" in */
|
||||||
strcpy(pFile, "server");
|
strcpy(pFile, "server");
|
||||||
} else {
|
} 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++;
|
iFile++;
|
||||||
if (iFile >= MAXFILES) {
|
if (iFile >= MAXFILES) {
|
||||||
iFile = 0;
|
iFile = 0;
|
||||||
|
Reference in New Issue
Block a user