From 844a19f9bfe01286ca9974aff0e6d38693e05877 Mon Sep 17 00:00:00 2001 From: pk33 Date: Sun, 3 Nov 2024 12:07:55 +0100 Subject: cleanup code & term handlers --- src/logger.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) (limited to 'src/logger.c') diff --git a/src/logger.c b/src/logger.c index c944da8..860311b 100644 --- a/src/logger.c +++ b/src/logger.c @@ -9,6 +9,7 @@ #include "string.h" #include "logger.h" +#include "options.h" Logger __logger; @@ -25,10 +26,15 @@ Size logger_init( void ) { String logfile[512]; + if( LOG_PATH[0] == '~' ) { + snprintf(logfile, 512, "%s/%s", getenv("HOME"), LOG_PATH+1); + } else { + snprintf(logfile, 512, "%s", LOG_PATH); + } - snprintf(logfile, 512, "%s/%s", getenv("HOME"), ".engine33.log"); - - __logger.fd = open(logfile, O_CREAT | O_WRONLY, S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH ); + __logger.fd = open(logfile, + O_CREAT | O_TRUNC | O_WRONLY | O_NOCTTY | O_TTY_INIT, + 0644 ); if( __logger.fd < 0 ) { printf( "Unable to initialize logger. Exiting." ); @@ -44,7 +50,7 @@ Size logger_init( void ) void logger_term( void ) { - dprintf( __logger.fd, "\r\n\r\nGoodbye!" ); + logi( "Goodbye!" ); close( __logger.fd ); } -- cgit v1.2.3