sys-logger: Optionally support mapping strongSwan loglevels to syslog levels

strongSwan logs all syslog messages using LOG_INFO for historical reasons,
regardless of the strongSwan loglevel used producing the log message.

In some setups with advanced logging infrastructure, it may be feasible
to be more verbose when logging in strongSwan, but then filter messages
on the syslog server. While this may be possible by custom syslog filtering
rules matching the log level included with the log_level setting, this is
not super convenient.

So add a new map_level setting, which can map strongSwan loglevels to
syslog loglevels. By default this is disabled, keeping the existing
behavior. If enabled, it maps strongSwan loglevels to syslog loglevels
at a given syslog loglevel offset.

Closes strongswan/strongswan#859
This commit is contained in:
Martin Willi
2022-01-24 17:33:02 +01:00
committed by Tobias Brunner
parent e3d1766aff
commit 9877ce6c56
4 changed files with 38 additions and 6 deletions
+4 -1
View File
@@ -451,6 +451,7 @@ static void load_sys_logger(private_daemon_t *this, char *facility,
debug_t group;
level_t def;
bool ike_name, log_level;
int map_level;
if (get_syslog_facility(facility) == -1)
{
@@ -467,8 +468,10 @@ static void load_sys_logger(private_daemon_t *this, char *facility,
FALSE, lib->ns, facility);
log_level = lib->settings->get_bool(lib->settings, "%s.syslog.%s.log_level",
FALSE, lib->ns, facility);
map_level = lib->settings->get_int(lib->settings, "%s.syslog.%s.map_level",
-1, lib->ns, facility);
sys_logger->set_options(sys_logger, ike_name, log_level);
sys_logger->set_options(sys_logger, ike_name, log_level, map_level);
def = lib->settings->get_int(lib->settings, "%s.syslog.%s.default", 1,
lib->ns, facility);