提交 2bdb4f41 authored 作者: Anthony Minessale's avatar Anthony Minessale

fix syslog (thanks justin unger)

git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@2702 d0543943-73ff-0310-b7d9-9358b9ac24b2
上级 78c7eff7
......@@ -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;
}
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论