]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
fix syslog (thanks justin unger)
authorAnthony Minessale <anthony.minessale@gmail.com>
Thu, 14 Sep 2006 18:58:38 +0000 (18:58 +0000)
committerAnthony Minessale <anthony.minessale@gmail.com>
Thu, 14 Sep 2006 18:58:38 +0000 (18:58 +0000)
git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@2702 d0543943-73ff-0310-b7d9-9358b9ac24b2

src/mod/loggers/mod_syslog/mod_syslog.c

index 82a004517463bdba3aa675bd740ce204cf8318d1..f8a9522a1d58705f50938e372038cd4febe08c4a 100644 (file)
@@ -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;
+}
+