[sr-dev] git:master:aa4c37ab: presence: Add local_log_facility configuration parameter

Phil Lavin phil.lavin at synety.com
Wed May 18 07:09:14 CEST 2016


Module: kamailio
Branch: master
Commit: aa4c37ab756b42f2aafc2b659d09bbe632f702a2
URL: https://github.com/kamailio/kamailio/commit/aa4c37ab756b42f2aafc2b659d09bbe632f702a2

Author: Phil Lavin <phil.lavin at synety.com>
Committer: Phil Lavin <phil.lavin at synety.com>
Date: 2016-05-17T09:46:25+01:00

presence: Add local_log_facility configuration parameter

Similar to local_log_level - controls the syslog facility of certain log entries

---

Modified: modules/presence/doc/presence_admin.xml
Modified: modules/presence/notify.c
Modified: modules/presence/presence.c

---

Diff:  https://github.com/kamailio/kamailio/commit/aa4c37ab756b42f2aafc2b659d09bbe632f702a2.diff
Patch: https://github.com/kamailio/kamailio/commit/aa4c37ab756b42f2aafc2b659d09bbe632f702a2.patch

---

diff --git a/modules/presence/doc/presence_admin.xml b/modules/presence/doc/presence_admin.xml
index 7558955..f1b8b6e 100644
--- a/modules/presence/doc/presence_admin.xml
+++ b/modules/presence/doc/presence_admin.xml
@@ -698,6 +698,25 @@ modparam("presence", "local_log_level", 3)
 </programlisting>
 	    </example>
 	</section>
+	<section id="presence.p.local_log_facility">
+	    <title><varname>local_log_facility</varname> (int)</title>
+	    <para>
+		Control syslog facility for some debug messages inside the module.
+	    </para>
+	    <para>
+		<emphasis>
+		    Default value is taken from the core log_facility configuration parameter.
+		</emphasis>
+	    </para>
+	    <example>
+		<title>Set <varname>local_log_facility</varname> parameter</title>
+		<programlisting format="linespecific">
+...
+modparam("presence", "local_log_facility", "LOG_LOCAL3")
+...
+</programlisting>
+	    </example>
+	</section>
 	<section id="presence.p.subs_remove_match">
 	    <title><varname>subs_remove_match</varname> (int)</title>
 	    <para>
diff --git a/modules/presence/notify.c b/modules/presence/notify.c
index 7e7b0b2..93d4274 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 92602b7..0b62527 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;
 




More information about the sr-dev mailing list