]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
reduce indentation / cleanup
authorMichael Jerris <mike@jerris.com>
Tue, 11 Dec 2007 03:32:21 +0000 (03:32 +0000)
committerMichael Jerris <mike@jerris.com>
Tue, 11 Dec 2007 03:32:21 +0000 (03:32 +0000)
git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@6622 d0543943-73ff-0310-b7d9-9358b9ac24b2

src/switch_console.c

index 2516720cc4daf9f90a3820f6ca9fd159986faabc..3c0da947e775c0d8e03a1b1058429e8951844247 100644 (file)
@@ -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);
-                       }
+       if (channel == SWITCH_CHANNEL_ID_LOG_CLEAN) {
+               fprintf(handle, "%s", data);
+               goto done;
+       }
 
-                       else if (channel == SWITCH_CHANNEL_ID_EVENT &&
-                                        switch_event_running() == SWITCH_STATUS_SUCCESS && switch_event_create(&event, SWITCH_EVENT_LOG) == SWITCH_STATUS_SUCCESS) {
+       switch_time_exp_lt(&tm, switch_timestamp_now());
+       switch_strftime(date, &retsize, sizeof(date), "%Y-%m-%d %T", &tm);
 
-                               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) {
+               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);
        }