daemon: Allow configuration of logfile path as value
Some characters are not allowed in section names, this way they can still be used in paths of log files.
This commit is contained in:
+13
-9
@@ -480,25 +480,29 @@ static void load_sys_logger(private_daemon_t *this, char *facility,
|
||||
/**
|
||||
* Load the given file logger configured in strongswan.conf
|
||||
*/
|
||||
static void load_file_logger(private_daemon_t *this, char *filename,
|
||||
static void load_file_logger(private_daemon_t *this, char *section,
|
||||
linked_list_t *current_loggers)
|
||||
{
|
||||
file_logger_t *file_logger;
|
||||
debug_t group;
|
||||
level_t def;
|
||||
bool add_ms, ike_name, flush_line, append;
|
||||
char *time_format;
|
||||
char *time_format, *filename;
|
||||
|
||||
time_format = lib->settings->get_str(lib->settings,
|
||||
"%s.filelog.%s.time_format", NULL, lib->ns, filename);
|
||||
"%s.filelog.%s.time_format", NULL, lib->ns, section);
|
||||
add_ms = lib->settings->get_bool(lib->settings,
|
||||
"%s.filelog.%s.time_add_ms", FALSE, lib->ns, filename);
|
||||
"%s.filelog.%s.time_add_ms", FALSE, lib->ns, section);
|
||||
ike_name = lib->settings->get_bool(lib->settings,
|
||||
"%s.filelog.%s.ike_name", FALSE, lib->ns, filename);
|
||||
"%s.filelog.%s.ike_name", FALSE, lib->ns, section);
|
||||
flush_line = lib->settings->get_bool(lib->settings,
|
||||
"%s.filelog.%s.flush_line", FALSE, lib->ns, filename);
|
||||
"%s.filelog.%s.flush_line", FALSE, lib->ns, section);
|
||||
append = lib->settings->get_bool(lib->settings,
|
||||
"%s.filelog.%s.append", TRUE, lib->ns, filename);
|
||||
"%s.filelog.%s.append", TRUE, lib->ns, section);
|
||||
time_format = lib->settings->get_str(lib->settings,
|
||||
"%s.filelog.%s.time_format", NULL, lib->ns, section);
|
||||
filename = lib->settings->get_str(lib->settings,
|
||||
"%s.filelog.%s.path", section, lib->ns, section);
|
||||
|
||||
file_logger = add_file_logger(this, filename, current_loggers);
|
||||
if (!file_logger)
|
||||
@@ -510,12 +514,12 @@ static void load_file_logger(private_daemon_t *this, char *filename,
|
||||
file_logger->open(file_logger, flush_line, append);
|
||||
|
||||
def = lib->settings->get_int(lib->settings, "%s.filelog.%s.default", 1,
|
||||
lib->ns, filename);
|
||||
lib->ns, section);
|
||||
for (group = 0; group < DBG_MAX; group++)
|
||||
{
|
||||
file_logger->set_level(file_logger, group,
|
||||
lib->settings->get_int(lib->settings, "%s.filelog.%s.%N", def,
|
||||
lib->ns, filename, debug_lower_names, group));
|
||||
lib->ns, section, debug_lower_names, group));
|
||||
}
|
||||
charon->bus->add_logger(charon->bus, &file_logger->logger);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user