Skip to content

Commit

Permalink
fix: move '.log' extension only if pass a valid file
Browse files Browse the repository at this point in the history
Signed-off-by: Juan Mesaglio <[email protected]>
  • Loading branch information
mesaglio committed Feb 4, 2025
1 parent 4b7ba90 commit d2c35a2
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions src/commons/log.c
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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) {
Expand Down

0 comments on commit d2c35a2

Please sign in to comment.