implemented why2_clean_memory in why2_init_logger
This commit is contained in:
parent
3a645d5167
commit
2a1e05886a
@ -27,6 +27,7 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
|
|
||||||
#include <why2/logger/flags.h>
|
#include <why2/logger/flags.h>
|
||||||
|
#include <why2/logger/utils.h>
|
||||||
|
|
||||||
#include <why2/encrypter.h>
|
#include <why2/encrypter.h>
|
||||||
#include <why2/memory.h>
|
#include <why2/memory.h>
|
||||||
@ -34,6 +35,8 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|||||||
|
|
||||||
why2_log_file why2_init_logger(char *directoryPath)
|
why2_log_file why2_init_logger(char *directoryPath)
|
||||||
{
|
{
|
||||||
|
why2_set_memory_identifier("logger_logfile_init");
|
||||||
|
|
||||||
//VARIABLES
|
//VARIABLES
|
||||||
struct stat st;
|
struct stat st;
|
||||||
struct dirent *entry;
|
struct dirent *entry;
|
||||||
@ -82,7 +85,14 @@ why2_log_file why2_init_logger(char *directoryPath)
|
|||||||
latestFilePath = why2_strdup(filePath);
|
latestFilePath = why2_strdup(filePath);
|
||||||
|
|
||||||
if (access(latestBuffer, R_OK) == 0) { unlink(latestBuffer); } //REMOVE SYMLINK IF IT ALREADY EXISTS
|
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:
|
deallocation:
|
||||||
|
|
||||||
@ -92,6 +102,8 @@ why2_log_file why2_init_logger(char *directoryPath)
|
|||||||
why2_free(latestFilePath);
|
why2_free(latestFilePath);
|
||||||
closedir(dir);
|
closedir(dir);
|
||||||
|
|
||||||
|
why2_reset_memory_identifier();
|
||||||
|
|
||||||
return (why2_log_file)
|
return (why2_log_file)
|
||||||
{
|
{
|
||||||
file,
|
file,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user