From 07094cea1d1e0cc2f7c6d26d85eec4a06a77a7ff Mon Sep 17 00:00:00 2001 From: netbenixcn Date: Sun, 7 Jun 2020 11:15:56 +0200 Subject: [PATCH] Changed Logger --- utils/logger.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/utils/logger.c b/utils/logger.c index c4c7147..1ff3478 100644 --- a/utils/logger.c +++ b/utils/logger.c @@ -1,14 +1,18 @@ #include #include #include +#include #include "logger.h" +char loggerDirPath[PATH_MAX]; void logger(char message[512]){ FILE *log_file; time_t t = time(NULL); struct tm tm = *localtime(&t); - log_file = fopen("output.log", "a"); + char buffer[1024]; + snprintf(buffer, sizeof(buffer), "%s/output.log", loggerDirPath); + log_file = fopen(buffer, "a"); fprintf(log_file, "[%d-%02d-%02d %02d:%02d:%02d] ", tm.tm_year + 1900, tm.tm_mon + 1, tm.tm_mday, tm.tm_hour, tm.tm_min, tm.tm_sec); fprintf(log_file, "%s\n", message); fclose(log_file);