]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
cleanup debug handling
authorAnthony Minessale <anthony.minessale@gmail.com>
Wed, 31 Dec 2008 16:52:11 +0000 (16:52 +0000)
committerAnthony Minessale <anthony.minessale@gmail.com>
Wed, 31 Dec 2008 16:52:11 +0000 (16:52 +0000)
git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@11023 d0543943-73ff-0310-b7d9-9358b9ac24b2

libs/esl/fs_cli.c
libs/esl/src/esl.c
libs/esl/src/include/esl.h
libs/esl/testclient.c
libs/esl/testserver.c

index dc34488a9e4b04a784ad10723a05bfdcb88c491c..657e7947249f4cddc29eb078476429da44654ad1 100644 (file)
@@ -106,6 +106,13 @@ static void *msg_thread_run(esl_thread_t *me, void *obj)
                                                known++;
                                        } else if (!strcasecmp(type, "text/disconnect-notice")) {
                                                running = thread_running = 0;
+                                               known++;
+                                       } else if (!strcasecmp(type, "text/event-plain")) {
+                                               char *foo;
+                                               esl_event_serialize(handle->last_ievent, &foo, ESL_FALSE);
+                                               printf("RECV EVENT\n%s\n", foo);
+                                               free(foo);
+
                                                known++;
                                        }
                                }
@@ -313,7 +320,6 @@ int main(int argc, char *argv[])
        
        signal(SIGINT, handle_SIGINT);
 
-       handle.debug = 0;
        esl_global_set_default_logger(6); /* default debug level to 6 (info) */
        
        for(;;) {
index 221968bdb01034f41a0d375dee117abe4ab8bc03..287fa1a8885ad338582aeaed22c112beeebc53fb 100644 (file)
@@ -370,10 +370,8 @@ ESL_DECLARE(esl_status_t) esl_sendevent(esl_handle_t *handle, esl_event_t *event
 
        esl_event_serialize(handle->last_ievent, &txt, ESL_TRUE);
 
-       if (handle->debug) {
-               esl_log(ESL_LOG_DEBUG, "SEND EVENT\n%s\n", txt);
-       }
-       
+       esl_log(ESL_LOG_DEBUG, "SEND EVENT\n%s\n", txt);
+               
        send(handle->sock, "sendevent\n", 10, 0);
        send(handle->sock, txt, strlen(txt), 0);
        send(handle->sock, "\n\n", 2, 0);
@@ -699,9 +697,7 @@ ESL_DECLARE(esl_status_t) esl_recv_event(esl_handle_t *handle, esl_event_t **sav
                                
                                if (hname && hval) {
                                        esl_url_decode(hval);
-                                       if (handle->debug > 1) {
-                                               esl_log(ESL_LOG_DEBUG, "RECV HEADER [%s] = [%s]\n", hname, hval);
-                                       }
+                                       esl_log(ESL_LOG_DEBUG, "RECV HEADER [%s] = [%s]\n", hname, hval);
                                        esl_event_add_header_string(revent, ESL_STACK_BOTTOM, hname, hval);
                                }
 
@@ -793,10 +789,7 @@ ESL_DECLARE(esl_status_t) esl_recv_event(esl_handle_t *handle, esl_event_t **sav
                        
                                if (hname && hval) {
                                        esl_url_decode(hval);
-
-                                       if (handle->debug > 1) {
-                                               esl_log(ESL_LOG_DEBUG, "RECV INNER HEADER [%s] = [%s]\n", hname, hval);
-                                       }
+                                       esl_log(ESL_LOG_DEBUG, "RECV INNER HEADER [%s] = [%s]\n", hname, hval);
                                        esl_event_add_header_string(handle->last_ievent, ESL_STACK_BOTTOM, hname, hval);
                                }
                                
@@ -825,8 +818,8 @@ ESL_DECLARE(esl_status_t) esl_recv_event(esl_handle_t *handle, esl_event_t **sav
                                handle->last_ievent->body = body;
                        }
 
-
-                       if (handle->debug) {
+                       
+                       if (esl_log_level >= 7) {
                                char *foo;
                                esl_event_serialize(handle->last_ievent, &foo, ESL_FALSE);
                                esl_log(ESL_LOG_DEBUG, "RECV EVENT\n%s\n", foo);
@@ -834,7 +827,7 @@ ESL_DECLARE(esl_status_t) esl_recv_event(esl_handle_t *handle, esl_event_t **sav
                        }
                }
                
-               if (handle->debug) {
+               if (esl_log_level >= 7) {
                        char *foo;
                        esl_event_serialize(revent, &foo, ESL_FALSE);
                        esl_log(ESL_LOG_DEBUG, "RECV MESSAGE\n%s\n", foo);
@@ -857,9 +850,7 @@ ESL_DECLARE(esl_status_t) esl_send(esl_handle_t *handle, const char *cmd)
 {
        const char *e = cmd + strlen(cmd) -1;
        
-       if (handle->debug) {
-               esl_log(ESL_LOG_DEBUG, "SEND\n%s\n", cmd);
-       }
+       esl_log(ESL_LOG_DEBUG, "SEND\n%s\n", cmd);
        
        if (send(handle->sock, cmd, strlen(cmd), 0) != (int)strlen(cmd)) {
                strerror_r(handle->errnum, handle->err, sizeof(handle->err));
index 56b414a228de45f20b46931d83e53a189343b9d7..100348cd40815254efaf1954263b39c5a759f802 100644 (file)
@@ -256,7 +256,6 @@ typedef struct {
        esl_event_t *last_sr_event;\r
        esl_event_t *last_ievent;\r
        esl_event_t *info_event;\r
-       int debug;\r
        int connected;\r
        struct sockaddr_in addr;\r
        esl_mutex_t *mutex;\r
index 4c61c1e58f28df5f0dbe594d3844b2f8e283064a..c9509049ebdfe4fab13fe203a8d2b4b55cdbbe07 100644 (file)
@@ -7,8 +7,6 @@ int main(void)
 {
        esl_handle_t handle = {{0}};
 
-       handle.debug = 1;
-       
        esl_connect(&handle, "localhost", 8021, "ClueCon");
 
        esl_send_recv(&handle, "api status\n\n");
index eec6ba50dadbe4706cf595cbc7a79467a9719615..5f3a413665ec54de013b7bcc625cb17d45bd39b8 100644 (file)
@@ -13,7 +13,6 @@ static void mycallback(esl_socket_t server_sock, esl_socket_t client_sock, struc
 
 
        esl_attach_handle(&handle, client_sock, addr);
-       handle.debug = 2;
 
        printf("Connected! %d\n", handle.sock);