From 421df597fab3174d96efd1a1a5ebcc52b9c98039 Mon Sep 17 00:00:00 2001 From: Karl Heyes 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. svn path=/trunk/icecast/; revision=5129 --- src/event.c | 1 + src/logging.c | 24 ++++++++++++++++++++++-- src/logging.h | 1 + 3 files changed, 24 insertions(+), 2 deletions(-) diff --git a/src/event.c b/src/event.c index 3e4e444a..ecba4d66 100644 --- a/src/event.c +++ b/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/src/logging.c b/src/logging.c index f9785d05..784739a0 100644 --- a/src/logging.c +++ b/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/src/logging.h b/src/logging.h index ae6d9b03..174ba036 100644 --- a/src/logging.h +++ b/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__ */