diff --git a/src/logger/lib/logger.c b/src/logger/lib/logger.c index 346ca77..bca618c 100644 --- a/src/logger/lib/logger.c +++ b/src/logger/lib/logger.c @@ -27,6 +27,7 @@ along with this program. If not, see . #include #include +#include #include #include @@ -34,6 +35,8 @@ along with this program. If not, see . why2_log_file why2_init_logger(char *directoryPath) { + why2_set_memory_identifier("logger_logfile_init"); + //VARIABLES struct stat st; struct dirent *entry; @@ -82,7 +85,14 @@ why2_log_file why2_init_logger(char *directoryPath) latestFilePath = why2_strdup(filePath); if (access(latestBuffer, R_OK) == 0) { unlink(latestBuffer); } //REMOVE SYMLINK IF IT ALREADY EXISTS - (void) (symlink(latestFilePath + (strlen(WHY2_WRITE_DIR) + 1), latestBuffer) + 1); //TODO: Try to create some function for processing exit value //CREATE + + if (symlink(latestFilePath + (strlen(WHY2_WRITE_DIR) + 1), latestBuffer) != 0) //CREATE SYMLINK + { + fprintf(stderr, "Creating symlink failed!\n"); + + why2_clean_memory("logger_logfile_init"); + return why2_empty_log_file(); + } deallocation: @@ -92,6 +102,8 @@ why2_log_file why2_init_logger(char *directoryPath) why2_free(latestFilePath); closedir(dir); + why2_reset_memory_identifier(); + return (why2_log_file) { file,