Index: gwlib/cfg.def =================================================================== --- gwlib/cfg.def (revision 4871) +++ gwlib/cfg.def (working copy) @@ -94,6 +94,8 @@ OCTSTR(wdp-interface-name) OCTSTR(log-file) OCTSTR(log-level) + OCTSTR(syslog-level) + OCTSTR(syslog-facility) OCTSTR(access-log) OCTSTR(access-log-time) OCTSTR(access-log-format) @@ -152,6 +154,7 @@ OCTSTR(log-file) OCTSTR(log-level) OCTSTR(syslog-level) + OCTSTR(syslog-facility) OCTSTR(smart-errors) OCTSTR(access-log) OCTSTR(access-log-time) @@ -263,6 +266,8 @@ OCTSTR(global-sender) OCTSTR(log-file) OCTSTR(log-level) + OCTSTR(syslog-level) + OCTSTR(syslog-facility) OCTSTR(access-log) OCTSTR(access-log-time) OCTSTR(access-log-clean) Index: gwlib/log.c =================================================================== --- gwlib/log.c (revision 4871) +++ gwlib/log.c (working copy) @@ -66,12 +66,14 @@ #include #include #include +#include #ifdef HAVE_EXECINFO_H #include #endif #if HAVE_SYSLOG_H +#define SYSLOG_NAMES #include #else @@ -144,9 +146,27 @@ * Syslog support. */ static int sysloglevel; +static int syslogfacility = LOG_DAEMON; static int dosyslog = 0; +/* + * Decode the syslog name to its int value + */ +int decode(char *name, CODE *facilities) +{ + register CODE *c; + if (isdigit(*name)) { + return (atoi(name)); + } + for (c = facilities; c->c_name; c++) { + if (!strcasecmp(name, c->c_name)) { + return (c->c_val); + } + } + return LOG_DAEMON; +} + /* * Make sure stderr is included in the list. */ @@ -212,6 +232,11 @@ } } +void log_set_syslog_facility(char *facility) +{ + if (facility != NULL) + syslogfacility = decode(facility, facilitynames); +} void log_set_syslog(const char *ident, int syslog_level) { @@ -220,7 +245,7 @@ else { dosyslog = 1; sysloglevel = syslog_level; - openlog(ident, LOG_PID, LOG_DAEMON); + openlog(ident, LOG_PID, syslogfacility); debug("gwlib.log", 0, "Syslog logging enabled."); } } Index: gwlib/log.h =================================================================== --- gwlib/log.h (revision 4871) +++ gwlib/log.h (working copy) @@ -138,6 +138,11 @@ void log_set_log_level(enum output_level level); /* + * Set the syslog facility to use. + */ +void log_set_syslog_facility(char *facility); + +/* * Set syslog usage. If `ident' is NULL, syslog is not used. */ void log_set_syslog(const char *ident, int syslog_level); Index: gw/bearerbox.c =================================================================== --- gw/bearerbox.c (revision 4871) +++ gw/bearerbox.c (working copy) @@ -369,7 +369,7 @@ static Cfg *init_bearerbox(Cfg *cfg) { CfgGroup *grp; - Octstr *log, *val; + Octstr *log, *val, *s; long loglevel, store_dump_freq, value; int lf, m; #ifdef HAVE_LIBSSL @@ -390,6 +390,25 @@ log_open(octstr_get_cstr(log), loglevel, GW_NON_EXCL); octstr_destroy(log); } + if ((s = cfg_get(grp, octstr_imm("syslog-level"))) != NULL) { + long level; + Octstr *facility; + if ((facility = cfg_get(grp, octstr_imm("syslog-facility"))) != NULL) { + log_set_syslog_facility(octstr_get_cstr(facility)); + octstr_destroy(facility); + } + if (octstr_compare(s, octstr_imm("none")) == 0) { + log_set_syslog(NULL, 0); + debug("bearerbox", 0, "syslog parameter is none"); + } else if (octstr_parse_long(&level, s, 0, 10) > 0) { + log_set_syslog("bearerbox", level); + debug("bearerbox", 0, "syslog parameter is %ld", level); + } + octstr_destroy(s); + } else { + log_set_syslog(NULL, 0); + debug("bearerbox", 0, "no syslog parameter"); + } if (check_config(cfg) == -1) panic(0, "Cannot start with corrupted configuration"); Index: gw/smsbox.c =================================================================== --- gw/smsbox.c (revision 4871) +++ gw/smsbox.c (working copy) @@ -3247,7 +3247,7 @@ { CfgGroup *grp; Octstr *logfile; - Octstr *p; + Octstr *p, *s; long lvl, value; Octstr *http_proxy_host = NULL; long http_proxy_port = -1; @@ -3403,6 +3403,25 @@ log_open(octstr_get_cstr(logfile), lvl, GW_NON_EXCL); octstr_destroy(logfile); } + if ((s = cfg_get(grp, octstr_imm("syslog-level"))) != NULL) { + long level; + Octstr *facility; + if ((facility = cfg_get(grp, octstr_imm("syslog-facility"))) != NULL) { + log_set_syslog_facility(octstr_get_cstr(facility)); + octstr_destroy(facility); + } + if (octstr_compare(s, octstr_imm("none")) == 0) { + log_set_syslog(NULL, 0); + debug("smsbox", 0, "syslog parameter is none"); + } else if (octstr_parse_long(&level, s, 0, 10) > 0) { + log_set_syslog("smsbox", level); + debug("smsbox", 0, "syslog parameter is %ld", level); + } + octstr_destroy(s); + } else { + log_set_syslog(NULL, 0); + debug("smsbox", 0, "no syslog parameter"); + } if (global_sender != NULL) { info(0, "Service global sender set as '%s'", octstr_get_cstr(global_sender)); Index: gw/wapbox.c =================================================================== --- gw/wapbox.c (revision 4871) +++ gw/wapbox.c (working copy) @@ -172,11 +172,15 @@ if ((s = cfg_get(grp, octstr_imm("syslog-level"))) != NULL) { long level; - + Octstr *facility; + if ((facility = cfg_get(grp, octstr_imm("syslog-facility"))) != NULL) { + log_set_syslog_facility(octstr_get_cstr(facility)); + octstr_destroy(facility); + } if (octstr_compare(s, octstr_imm("none")) == 0) { log_set_syslog(NULL, 0); debug("wap", 0, "syslog parameter is none"); - } else if (octstr_parse_long(&level, s, 0, 0) == -1) { + } else if (octstr_parse_long(&level, s, 0, 10) > 0) { log_set_syslog("wapbox", level); debug("wap", 0, "syslog parameter is %ld", level); }