From aa4c37ab756b42f2aafc2b659d09bbe632f702a2 Mon Sep 17 00:00:00 2001 From: Phil Lavin Date: Tue, 17 May 2016 09:41:55 +0100 Subject: [PATCH] presence: Add local_log_facility configuration parameter Similar to local_log_level - controls the syslog facility of certain log entries --- modules/presence/doc/presence_admin.xml | 19 +++++++++++++++++++ modules/presence/notify.c | 3 ++- modules/presence/presence.c | 19 +++++++++++++++++++ 3 files changed, 40 insertions(+), 1 deletion(-) diff --git a/modules/presence/doc/presence_admin.xml b/modules/presence/doc/presence_admin.xml index 7558955ad2b..f1b8b6e849f 100644 --- a/modules/presence/doc/presence_admin.xml +++ b/modules/presence/doc/presence_admin.xml @@ -695,6 +695,25 @@ modparam("presence", "db_table_lock_type", 0) ... modparam("presence", "local_log_level", 3) ... + + + +
+ <varname>local_log_facility</varname> (int) + + Control syslog facility for some debug messages inside the module. + + + + Default value is taken from the core log_facility configuration parameter. + + + + Set <varname>local_log_facility</varname> parameter + +... +modparam("presence", "local_log_facility", "LOG_LOCAL3") +...
diff --git a/modules/presence/notify.c b/modules/presence/notify.c index 7e7b0b25e2d..93d427436b7 100644 --- a/modules/presence/notify.c +++ b/modules/presence/notify.c @@ -54,6 +54,7 @@ int goto_on_notify_reply=-1; extern int pres_local_log_level; +extern int pres_local_log_facility; c_back_param* shm_dup_cbparam(subs_t*); void free_cbparam(c_back_param* cb_param); @@ -1613,7 +1614,7 @@ int send_notify_request(subs_t* subs, subs_t * watcher_subs, goto error; } - LM_GEN1(pres_local_log_level, + LM_GEN2(pres_local_log_facility, pres_local_log_level, "NOTIFY %.*s via %.*s on behalf of %.*s for event %.*s : %.*s\n", td->rem_uri.len, td->rem_uri.s, td->hooks.next_hop->len, td->hooks.next_hop->s, diff --git a/modules/presence/presence.c b/modules/presence/presence.c index 92602b7d045..0b6252761bf 100644 --- a/modules/presence/presence.c +++ b/modules/presence/presence.c @@ -84,6 +84,9 @@ static int clean_period=100; static int db_update_period=100; int pres_local_log_level = L_INFO; +static char * pres_log_facility_str = 0; /*!< Syslog: log facility that is used */ +int pres_local_log_facility; + /* database connection */ db1_con_t *pa_db = NULL; db_func_t pa_dbf; @@ -217,6 +220,7 @@ static param_export_t params[]={ { "fetch_rows", INT_PARAM, &pres_fetch_rows}, { "db_table_lock_type", INT_PARAM, &db_table_lock_type}, { "local_log_level", PARAM_INT, &pres_local_log_level}, + { "local_log_facility", PARAM_STR, &pres_log_facility_str}, { "subs_remove_match", PARAM_INT, &pres_subs_remove_match}, { "xavp_cfg", PARAM_STR, &pres_xavp_cfg}, { "retrieve_order", PARAM_INT, &pres_retrieve_order}, @@ -436,6 +440,21 @@ static int mod_init(void) if (pres_force_delete > 0) pres_force_delete = 1; + if (pres_log_facility_str) { + int tmp = str2facility(pres_log_facility_str); + + if (tmp != -1) { + pres_local_log_facility = tmp; + } + else { + LM_ERR("invalid log facility configured\n"); + return -1; + } + } + else { + pres_local_log_facility = cfg_get(core, core_cfg, log_facility); + } + if (db_table_lock_type != 1) db_table_lock = DB_LOCKING_NONE;