From 2cad2a3bcd36fed0324f967f7fce1ae67da1d2c9 Mon Sep 17 00:00:00 2001 From: Michael Jerris Date: Tue, 11 Dec 2007 03:32:21 +0000 Subject: [PATCH] reduce indentation / cleanup git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@6622 d0543943-73ff-0310-b7d9-9358b9ac24b2 --- src/switch_console.c | 62 +++++++++++++++++++++++--------------------- 1 file changed, 33 insertions(+), 29 deletions(-) diff --git a/src/switch_console.c b/src/switch_console.c index 2516720cc4..3c0da947e7 100644 --- a/src/switch_console.c +++ b/src/switch_console.c @@ -146,44 +146,48 @@ SWITCH_DECLARE(void) switch_console_printf(switch_text_channel_t channel, const char *data = NULL; int ret = 0; va_list ap; - FILE *handle; + FILE *handle = switch_core_data_channel(channel); const char *filep = switch_cut_path(file); + char date[80] = ""; + switch_size_t retsize; + switch_time_exp_t tm; + switch_event_t *event; va_start(ap, fmt); - - handle = switch_core_data_channel(channel); - ret = switch_vasprintf(&data, fmt, ap); va_end(ap); + if (ret == -1) { fprintf(stderr, "Memory Error\n"); - } else { - char date[80] = ""; + goto done; + } - if (channel == SWITCH_CHANNEL_ID_LOG_CLEAN) { - fprintf(handle, "%s", data); - } else { - switch_size_t retsize; - switch_time_exp_t tm; - switch_event_t *event; - switch_time_exp_lt(&tm, switch_timestamp_now()); - switch_strftime(date, &retsize, sizeof(date), "%Y-%m-%d %T", &tm); - - if (channel == SWITCH_CHANNEL_ID_LOG) { - fprintf(handle, "[%d] %s %s:%d %s() %s", (int) getpid(), date, filep, line, func, data); - } - - else if (channel == SWITCH_CHANNEL_ID_EVENT && - switch_event_running() == SWITCH_STATUS_SUCCESS && switch_event_create(&event, SWITCH_EVENT_LOG) == SWITCH_STATUS_SUCCESS) { - - switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Log-Data", "%s", data); - switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Log-File", "%s", filep); - switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Log-Function", "%s", func); - switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Log-Line", "%d", line); - switch_event_fire(&event); - } - } + if (channel == SWITCH_CHANNEL_ID_LOG_CLEAN) { + fprintf(handle, "%s", data); + goto done; } + + switch_time_exp_lt(&tm, switch_timestamp_now()); + switch_strftime(date, &retsize, sizeof(date), "%Y-%m-%d %T", &tm); + + if (channel == SWITCH_CHANNEL_ID_LOG) { + fprintf(handle, "[%d] %s %s:%d %s() %s", (int) getpid(), date, filep, line, func, data); + goto done; + } + + if (channel == SWITCH_CHANNEL_ID_EVENT && + switch_event_running() == SWITCH_STATUS_SUCCESS && + switch_event_create(&event, SWITCH_EVENT_LOG) == SWITCH_STATUS_SUCCESS) { + + switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Log-Data", "%s", data); + switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Log-File", "%s", filep); + switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Log-Function", "%s", func); + switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Log-Line", "%d", line); + switch_event_fire(&event); + } + + +done: if (data) { free(data); }