cleanup debug handling

git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@11023 d0543943-73ff-0310-b7d9-9358b9ac24b2
This commit is contained in:
Anthony Minessale 2008-12-31 16:52:11 +00:00
parent 0b8ec49dd8
commit c6b3871eb0
5 changed files with 15 additions and 22 deletions

View 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(;;) {

View 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));

View File

@ -256,7 +256,6 @@ typedef struct {
esl_event_t *last_sr_event;
esl_event_t *last_ievent;
esl_event_t *info_event;
int debug;
int connected;
struct sockaddr_in addr;
esl_mutex_t *mutex;

View 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");

View 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);