Commit 421df597 authored by Karl Heyes's avatar Karl Heyes

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
parent d6377818
......@@ -39,6 +39,7 @@ void event_config_read(void *arg)
else {
config_clear(config);
config_set_config(&new_config);
restart_logging ();
config_release_config();
}
......
#include <stdio.h>
#include <time.h>
#include <string.h>
#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);
}
}
......@@ -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__ */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment