added some *working* code into writeLog's body

This commit is contained in:
Václav Šmejkal 2022-11-22 18:47:56 +01:00
parent 6074e06e9f
commit 0f4492a611
No known key found for this signature in database
GPG Key ID: FD749A97DF2D5E19

View File

@ -56,5 +56,15 @@ int initLogger(char *directoryPath)
void writeLog(int loggerFile, char *logMessage)
{
write(loggerFile, logMessage, strlen(logMessage));
//VARIABLES
char *buffer = malloc(strlen(WRITE_FORMAT) + strlen(logMessage) + 1);
time_t timeL = time(NULL);
struct tm tm = *localtime(&timeL);
sprintf(buffer, WRITE_FORMATTING, tm.tm_hour, tm.tm_min, tm.tm_sec, logMessage); //LOAD MESSAGE
write(loggerFile, buffer, strlen(buffer)); //WRITE (YAY)
//DEALLOCATION
free(buffer);
}