Skip to content

Commit

Permalink
presence: Add local_log_facility configuration parameter
Browse files Browse the repository at this point in the history
Similar to local_log_level - controls the syslog facility of certain log entries
  • Loading branch information
Phil Lavin committed May 17, 2016
1 parent 472782d commit aa4c37a
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 1 deletion.
19 changes: 19 additions & 0 deletions modules/presence/doc/presence_admin.xml
Expand Up @@ -695,6 +695,25 @@ modparam("presence", "db_table_lock_type", 0)
...
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>
Expand Down
3 changes: 2 additions & 1 deletion modules/presence/notify.c
Expand Up @@ -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);
Expand Down Expand Up @@ -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,
Expand Down
19 changes: 19 additions & 0 deletions modules/presence/presence.c
Expand Up @@ -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;
Expand Down Expand Up @@ -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},
Expand Down Expand Up @@ -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;

Expand Down

0 comments on commit aa4c37a

Please sign in to comment.