From: Anthony Minessale Date: Thu, 14 Sep 2006 18:58:38 +0000 (+0000) Subject: fix syslog (thanks justin unger) X-Git-Tag: v1.0-beta1~2134 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=2bdb4f41b3102ed1b973c3163f06caeb5282ded5;p=thirdparty%2Ffreeswitch.git fix syslog (thanks justin unger) git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@2702 d0543943-73ff-0310-b7d9-9358b9ac24b2 --- diff --git a/src/mod/loggers/mod_syslog/mod_syslog.c b/src/mod/loggers/mod_syslog/mod_syslog.c index 82a0045174..f8a9522a1d 100644 --- a/src/mod/loggers/mod_syslog/mod_syslog.c +++ b/src/mod/loggers/mod_syslog/mod_syslog.c @@ -103,42 +103,19 @@ static switch_status_t mod_syslog_logger(const switch_log_node_t *node, switch_l return SWITCH_STATUS_SUCCESS; } -SWITCH_MOD_DECLARE(switch_status_t) switch_module_load(const switch_loadable_module_interface_t **interface, char *filename) -{ - switch_status_t status; - *interface = &console_module_interface; - - if ((status=load_config()) != SWITCH_STATUS_SUCCESS) { - return status; - } - - openlog(globals.ident, LOG_PID, LOG_USER); - - switch_log_bind_logger(mod_syslog_logger, SWITCH_LOG_DEBUG); - - return SWITCH_STATUS_SUCCESS; -} - -SWITCH_MOD_DECLARE(switch_status_t) switch_module_unload(const switch_loadable_module_interface_t **interface) -{ - closelog(); - - return SWITCH_STATUS_SUCCESS; -} - static switch_status_t load_config(void) { - switch_config_t cfg; - char *var, *val; char *cf = "syslog.conf"; + switch_xml_t cfg, xml, settings, param; - memset(&globals, 0, sizeof(globals)); - - if (switch_config_open_file(&cfg, cf)) { + if (!(xml = switch_xml_open_cfg(cf, &cfg, NULL))) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "open of %s failed\n", cf); + } else { + if ((settings = switch_xml_child(cfg, "settings"))) { + for (param = switch_xml_child(settings, "param"); param; param = param->next) { + char *var = (char *) switch_xml_attr_soft(param, "name"); + char *val = (char *) switch_xml_attr_soft(param, "value"); - while (switch_config_next_pair(&cfg, &var, &val)) { - if (!strcasecmp(cfg.category, "settings")) { if (!strcmp(var, "ident")) { set_global_ident(val); } else if (!strcmp(var, "facility")) { @@ -148,12 +125,12 @@ static switch_status_t load_config(void) } else if (!strcmp(var, "level")) { set_global_level(val);; } + } } - - switch_config_close_file(&cfg); + switch_xml_free(xml); } - + if (switch_strlen_zero(globals.ident)) { set_global_ident(DEFAULT_IDENT); } @@ -167,5 +144,30 @@ static switch_status_t load_config(void) set_global_level(DEFAULT_LEVEL); } + + return 0; +} + +SWITCH_MOD_DECLARE(switch_status_t) switch_module_load(const switch_loadable_module_interface_t **interface, char *filename) +{ + switch_status_t status; + *interface = &console_module_interface; + + if ((status=load_config()) != SWITCH_STATUS_SUCCESS) { + return status; + } + + openlog(globals.ident, LOG_PID, LOG_USER); + + switch_log_bind_logger(mod_syslog_logger, SWITCH_LOG_DEBUG); + return SWITCH_STATUS_SUCCESS; } + +SWITCH_MOD_DECLARE(switch_status_t) switch_module_unload(const switch_loadable_module_interface_t **interface) +{ + closelog(); + + return SWITCH_STATUS_SUCCESS; +} +