diff --git a/src/switch_core.c b/src/switch_core.c index 8a24644732..b766dfd8a9 100644 --- a/src/switch_core.c +++ b/src/switch_core.c @@ -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,26 +1194,22 @@ 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; } + 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_load_core_config("switch.conf"); - switch_log_init(runtime.memory_pool, runtime.colorize_console); + switch_core_state_machine_init(runtime.memory_pool); - *err = NULL; - - if (console) { - runtime.console = stdout; - } - if (switch_test_flag((&runtime), SCF_USE_SQL)) { switch_core_sqldb_start(runtime.memory_pool); } diff --git a/src/switch_nat.c b/src/switch_nat.c index 1b9d3cab63..d8add7f18b 100644 --- a/src/switch_nat.c +++ b/src/switch_nat.c @@ -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"); } } diff --git a/src/switch_xml.c b/src/switch_xml.c index 3ed3dcb7ef..057958c14e 100644 --- a/src/switch_xml.c +++ b/src/switch_xml.c @@ -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 or for the sake of validators as well as type stuff */