fixed logger's todo

and deallocated filePath
This commit is contained in:
Václav Šmejkal 2022-11-21 11:57:49 +00:00
parent ddb5389916
commit 4a7f3ac3ab

View File

@ -18,6 +18,7 @@ int initLogger(char *directoryPath)
time_t timeL = time(NULL);
struct tm tm = *localtime(&timeL);
int buffer = 1;
int returning;
char *filePath = malloc(strlen(directoryPath) + strlen(LOG_FORMAT) + 1);
DIR *dir;
@ -43,11 +44,11 @@ int initLogger(char *directoryPath)
sprintf(filePath, "%s/%04d-%02d-%02d_%03x", directoryPath, tm.tm_year + 1900, tm.tm_mon + 1, tm.tm_mday, buffer);
returning = open(filePath, O_WRONLY | O_APPEND | O_CREAT, 0644);
//DEALLOCATION
//free(filePath);
free(filePath);
closedir(dir);
return open(filePath, O_WRONLY | O_APPEND | O_CREAT, 0644);
}
//TODO: fix filePath deallocation somehow
return returning;
}