parent
a3f5e38b7f
commit
b422f16d10
|
@ -67,3 +67,6 @@ charon.syslog.<facility>.<subsystem> = <default>
|
|||
charon.syslog.<facility>.ike_name = no
|
||||
Prefix each log entry with the connection name and a unique numerical
|
||||
identifier for each IKE_SA.
|
||||
|
||||
charon.syslog.<facility>.log_level = no
|
||||
Add the log level of each message after the subsystem (e.g. [IKE2]).
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (C) 2012 Tobias Brunner
|
||||
* Copyright (C) 2012-2020 Tobias Brunner
|
||||
* Copyright (C) 2006 Martin Willi
|
||||
* HSR Hochschule fuer Technik Rapperswil
|
||||
*
|
||||
|
@ -50,6 +50,11 @@ struct private_sys_logger_t {
|
|||
*/
|
||||
bool ike_name;
|
||||
|
||||
/**
|
||||
* Print the log level
|
||||
*/
|
||||
bool log_level;
|
||||
|
||||
/**
|
||||
* Mutex to ensure multi-line log messages are not torn apart
|
||||
*/
|
||||
|
@ -65,13 +70,21 @@ METHOD(logger_t, log_, void,
|
|||
private_sys_logger_t *this, debug_t group, level_t level, int thread,
|
||||
ike_sa_t* ike_sa, const char *message)
|
||||
{
|
||||
char groupstr[4], namestr[128] = "";
|
||||
char groupstr[5], namestr[128] = "";
|
||||
const char *current = message, *next;
|
||||
|
||||
/* cache group name and optional name string */
|
||||
snprintf(groupstr, sizeof(groupstr), "%N", debug_names, group);
|
||||
|
||||
this->lock->read_lock(this->lock);
|
||||
if (this->log_level)
|
||||
{
|
||||
snprintf(groupstr, sizeof(groupstr), "%N%d", debug_names, group,
|
||||
level);
|
||||
}
|
||||
else
|
||||
{
|
||||
snprintf(groupstr, sizeof(groupstr), "%N", debug_names, group);
|
||||
}
|
||||
|
||||
if (this->ike_name && ike_sa)
|
||||
{
|
||||
if (ike_sa->get_peer_cfg(ike_sa))
|
||||
|
@ -135,10 +148,11 @@ METHOD(sys_logger_t, set_level, void,
|
|||
}
|
||||
|
||||
METHOD(sys_logger_t, set_options, void,
|
||||
private_sys_logger_t *this, bool ike_name)
|
||||
private_sys_logger_t *this, bool ike_name, bool log_level)
|
||||
{
|
||||
this->lock->write_lock(this->lock);
|
||||
this->ike_name = ike_name;
|
||||
this->log_level = log_level;
|
||||
this->lock->unlock(this->lock);
|
||||
}
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (C) 2012 Tobias Brunner
|
||||
* Copyright (C) 2012-2020 Tobias Brunner
|
||||
* Copyright (C) 2006 Martin Willi
|
||||
* HSR Hochschule fuer Technik Rapperswil
|
||||
*
|
||||
|
@ -48,8 +48,9 @@ struct sys_logger_t {
|
|||
* Set options used by this logger.
|
||||
*
|
||||
* @param ike_name TRUE to prefix the name of the IKE_SA
|
||||
* @param log_level TRUE to include the log level in the message
|
||||
*/
|
||||
void (*set_options) (sys_logger_t *this, bool ike_name);
|
||||
void (*set_options) (sys_logger_t *this, bool ike_name, bool log_level);
|
||||
|
||||
/**
|
||||
* Destroys a sys_logger_t object.
|
||||
|
|
|
@ -450,6 +450,7 @@ static void load_sys_logger(private_daemon_t *this, char *facility,
|
|||
sys_logger_t *sys_logger;
|
||||
debug_t group;
|
||||
level_t def;
|
||||
bool ike_name, log_level;
|
||||
|
||||
if (get_syslog_facility(facility) == -1)
|
||||
{
|
||||
|
@ -462,9 +463,12 @@ static void load_sys_logger(private_daemon_t *this, char *facility,
|
|||
return;
|
||||
}
|
||||
|
||||
sys_logger->set_options(sys_logger,
|
||||
lib->settings->get_bool(lib->settings, "%s.syslog.%s.ike_name",
|
||||
FALSE, lib->ns, facility));
|
||||
ike_name = lib->settings->get_bool(lib->settings, "%s.syslog.%s.ike_name",
|
||||
FALSE, lib->ns, facility);
|
||||
log_level = lib->settings->get_bool(lib->settings, "%s.syslog.%s.log_level",
|
||||
FALSE, lib->ns, facility);
|
||||
|
||||
sys_logger->set_options(sys_logger, ike_name, log_level);
|
||||
|
||||
def = lib->settings->get_int(lib->settings, "%s.syslog.%s.default", 1,
|
||||
lib->ns, facility);
|
||||
|
|
Loading…
Reference in New Issue