]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
fix order of ops to enable logging sooner
authorAnthony Minessale <anthony.minessale@gmail.com>
Tue, 2 Jun 2009 22:03:33 +0000 (22:03 +0000)
committerAnthony Minessale <anthony.minessale@gmail.com>
Tue, 2 Jun 2009 22:03:33 +0000 (22:03 +0000)
git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@13556 d0543943-73ff-0310-b7d9-9358b9ac24b2

src/switch_core.c
src/switch_nat.c
src/switch_xml.c

index 8a2464473250fd97dabd8b0d70d6fe64f389792b..b766dfd8a92287ee624cb66485c2e5d3771ef9ec 100644 (file)
@@ -1176,6 +1176,12 @@ SWITCH_DECLARE(switch_status_t) switch_core_init(switch_core_flag_t flags, switc
        runtime.flags = flags;
        runtime.sps_total = 30;
 
+       *err = NULL;
+
+       if (console) {
+               runtime.console = stdout;
+       }
+
        switch_find_local_ip(guess_ip, sizeof(guess_ip), &mask, AF_INET);
        switch_core_set_variable("local_ip_v4", guess_ip);
        switch_core_set_variable("local_mask_v4", inet_ntoa(*(struct in_addr *)&mask));
@@ -1188,25 +1194,21 @@ SWITCH_DECLARE(switch_status_t) switch_core_init(switch_core_flag_t flags, switc
 
        switch_event_init(runtime.memory_pool);
 
-       if (switch_test_flag((&runtime), SCF_USE_AUTO_NAT)) {
-               switch_nat_init(runtime.memory_pool);
-       }
-
        if (switch_xml_init(runtime.memory_pool, err) != SWITCH_STATUS_SUCCESS) {
                apr_terminate();
                return SWITCH_STATUS_MEMERR;
        }
 
-       switch_load_core_config("switch.conf");
-
+       if (switch_test_flag((&runtime), SCF_USE_AUTO_NAT)) {
+               switch_nat_init(runtime.memory_pool);
+       }
+       
        switch_log_init(runtime.memory_pool, runtime.colorize_console);
-       switch_core_state_machine_init(runtime.memory_pool);
 
-       *err = NULL;
+       switch_load_core_config("switch.conf");
 
-       if (console) {
-               runtime.console = stdout;
-       }
+
+       switch_core_state_machine_init(runtime.memory_pool);
 
        if (switch_test_flag((&runtime), SCF_USE_SQL)) {
                switch_core_sqldb_start(runtime.memory_pool);
index 1b9d3cab63c47913e87a229def768b122842fda7..d8add7f18b663437e169ff9678cfce2a4d4081d4 100644 (file)
@@ -146,9 +146,14 @@ SWITCH_DECLARE(void) switch_nat_init(switch_memory_pool_t *pool)
 
        switch_find_local_ip(nat_globals.pvt_addr, sizeof(nat_globals.pvt_addr), NULL, AF_INET);
 
+
+       switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Detecting NAT\n");
+
+       switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Checking for PMP\n");
        init_pmp();
 
-       if (!nat_globals.nat_type) {
+       if (nat_globals.nat_type) {
+               switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Checking for UPNP\n");
                init_upnp();
        }
        
@@ -156,8 +161,9 @@ SWITCH_DECLARE(void) switch_nat_init(switch_memory_pool_t *pool)
                switch_core_set_variable("nat_public_addr", nat_globals.pub_addr);
                switch_core_set_variable("nat_private_addr", nat_globals.pvt_addr);
                switch_core_set_variable("nat_type", nat_globals.nat_type == SWITCH_NAT_TYPE_PMP ? "pmp" : "upnp");
+               switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "NAT detected type: %s\n", nat_globals.nat_type == SWITCH_NAT_TYPE_PMP ? "pmp" : "upnp");
        } else {
-               switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "No PMP or uPNP NAT device detected!\n");
+               switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "No PMP or uPNP NAT device detected!\n");
        }
 }
 
index 3ed3dcb7ef62345f41f32c7f0718e36bb3dcd79f..057958c14eb9a17aafbf708271e0040fbfc2d6ee 100644 (file)
@@ -1287,8 +1287,8 @@ static int preprocess(const char *cwd, const char *file, int write_fd, int rleve
                char *bp = expand_vars(buf, ebuf, sizeof(ebuf), &cur, &err);
                line++;
                
-               if (err && stderr) {
-                       fprintf(stderr, "Error [%s] in file %s line %d\n", err, file, line);
+               if (err) {
+                       switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error [%s] in file %s line %d\n", err, file, line);
                }
 
                /* we ignore <include> or </include> for the sake of validators as well as <?xml version="1.0"?> type stuff */