diff options
author | pk33 <pk33@email.com> | 2024-11-03 12:07:55 +0100 |
---|---|---|
committer | pk33 <pk33@email.com> | 2024-11-03 12:07:55 +0100 |
commit | 844a19f9bfe01286ca9974aff0e6d38693e05877 (patch) | |
tree | beca8efb8300fe3b6c78e9da26560cf674b57595 /src/logger.c | |
parent | 23ab6c4e6483159b77af8b4edf95113887a300d7 (diff) | |
download | engine33-844a19f9bfe01286ca9974aff0e6d38693e05877.tar.gz |
cleanup code & term handlers
Diffstat (limited to 'src/logger.c')
-rw-r--r-- | src/logger.c | 14 |
1 files changed, 10 insertions, 4 deletions
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 ); } |