From dad0842fd54f626fbac5f5def9a1430a2f45f0b6 Mon Sep 17 00:00:00 2001 From: Juan Mesaglio Date: Mon, 3 Feb 2025 22:20:04 -0300 Subject: [PATCH] fix: move '.log' extension only if pass a valid file Signed-off-by: Juan Mesaglio --- src/commons/log.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/commons/log.c b/src/commons/log.c index 3412fd5..25d92d7 100644 --- a/src/commons/log.c +++ b/src/commons/log.c @@ -44,11 +44,6 @@ static bool _is_level_enabled(t_log* logger, t_log_level level); t_log* log_create(char* file, char *program_name, bool is_active_console, t_log_level detail) { - if (!string_ends_with(file, ".log")) { - perror("Log file must have .log extension"); - return NULL; - } - t_log* logger = malloc(sizeof(t_log)); if (logger == NULL) { @@ -59,6 +54,10 @@ t_log* log_create(char* file, char *program_name, bool is_active_console, t_log_ FILE *file_opened = NULL; if (file != NULL) { + if (!string_ends_with(file, ".log")) { + error_show("Log file must have .log extension"); + return NULL; + } file_opened = txt_open_for_append(file); if (file_opened == NULL) {