From 3e1c093b3f0233b3b4ffd0c4f66b0f9b86855884 Mon Sep 17 00:00:00 2001 From: karl Date: Fri, 11 Jul 2003 23:54:50 +0000 Subject: [PATCH] Add log cycling on HUP signals. Currently reopens log files in append mode so allows for continuing the log, or cycling just one log. log filename changes work as well. git-svn-id: http://svn.xiph.org/trunk@5129 0101bb08-14d6-0310-b084-bc0e0c8e3800 --- icecast/src/event.c | 1 + icecast/src/logging.c | 28 ++++++++++++++++++++++++---- icecast/src/logging.h | 1 + 3 files changed, 26 insertions(+), 4 deletions(-) diff --git a/icecast/src/event.c b/icecast/src/event.c index 3e4e444ad..ecba4d668 100644 --- a/icecast/src/event.c +++ b/icecast/src/event.c @@ -39,6 +39,7 @@ void event_config_read(void *arg) else { config_clear(config); config_set_config(&new_config); + restart_logging (); config_release_config(); } diff --git a/icecast/src/logging.c b/icecast/src/logging.c index f9785d057..784739a0e 100644 --- a/icecast/src/logging.c +++ b/icecast/src/logging.c @@ -1,5 +1,6 @@ #include #include +#include #include "thread.h" #include "httpp.h" @@ -9,6 +10,8 @@ #include "refbuf.h" #include "client.h" +#include "os.h" +#include "config.h" #include "logging.h" #ifdef _WIN32 @@ -69,7 +72,24 @@ void logging_access(client_t *client) - - - - +void restart_logging () +{ + ice_config_t *config = config_get_config_unlocked(); + + if (strcmp (config->error_log, "-")) + { + char fn_error[FILENAME_MAX]; + snprintf (fn_error, FILENAME_MAX, "%s%s%s", config->log_dir, PATH_SEPARATOR, config->error_log); + log_set_filename (errorlog, fn_error); + log_set_level (errorlog, config->loglevel); + log_reopen (errorlog); + } + + if (strcmp (config->access_log, "-")) + { + char fn_error[FILENAME_MAX]; + snprintf (fn_error, FILENAME_MAX, "%s%s%s", config->log_dir, PATH_SEPARATOR, config->access_log); + log_set_filename (accesslog, fn_error); + log_reopen (accesslog); + } +} diff --git a/icecast/src/logging.h b/icecast/src/logging.h index ae6d9b032..174ba036b 100644 --- a/icecast/src/logging.h +++ b/icecast/src/logging.h @@ -75,6 +75,7 @@ extern int accesslog; #define LOGGING_FORMAT_CLF "%d/%b/%Y:%H:%M:%S %z" void logging_access(client_t *client); +void restart_logging (void); #endif /* __LOGGING_H__ */ -- 2.11.4.GIT