[Freeswitch-svn] [commit] r2702 - freeswitch/trunk/src/mod/loggers/mod_syslog

Freeswitch SVN anthm at freeswitch.org
Thu Sep 14 14:58:39 EDT 2006


Author: anthm
Date: Thu Sep 14 14:58:38 2006
New Revision: 2702

Modified:
   freeswitch/trunk/src/mod/loggers/mod_syslog/mod_syslog.c

Log:
fix syslog (thanks justin unger)

Modified: freeswitch/trunk/src/mod/loggers/mod_syslog/mod_syslog.c
==============================================================================
--- freeswitch/trunk/src/mod/loggers/mod_syslog/mod_syslog.c	(original)
+++ freeswitch/trunk/src/mod/loggers/mod_syslog/mod_syslog.c	Thu Sep 14 14:58:38 2006
@@ -103,42 +103,19 @@
 	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 @@
 				} 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 @@
 		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;
+}
+



More information about the Freeswitch-svn mailing list