From: Enlightenment S. <no-...@en...> - 2011-03-24 04:35:32
|
Log: +EAPI void azy_rpc_log_enable(void); Author: discomfitor Date: 2011-03-23 21:35:25 -0700 (Wed, 23 Mar 2011) New Revision: 58060 Trac: http://trac.enlightenment.org/e/changeset/58060 Modified: trunk/PROTO/azy/src/include/Azy.h trunk/PROTO/azy/src/include/azy_private.h trunk/PROTO/azy/src/lib/azy_client_events.c trunk/PROTO/azy/src/lib/azy_lib.c trunk/PROTO/azy/src/lib/azy_server_events.c Modified: trunk/PROTO/azy/src/include/Azy.h =================================================================== --- trunk/PROTO/azy/src/include/Azy.h 2011-03-24 04:15:41 UTC (rev 58059) +++ trunk/PROTO/azy/src/include/Azy.h 2011-03-24 04:35:25 UTC (rev 58060) @@ -264,8 +264,9 @@ #endif /* library */ - EAPI int azy_init(void); - EAPI int azy_shutdown(void); + EAPI int azy_init(void); + EAPI int azy_shutdown(void); + EAPI void azy_rpc_log_enable(void); /* utils */ EAPI char *azy_base64_encode(const char *string, Modified: trunk/PROTO/azy/src/include/azy_private.h =================================================================== --- trunk/PROTO/azy/src/include/azy_private.h 2011-03-24 04:15:41 UTC (rev 58059) +++ trunk/PROTO/azy/src/include/azy_private.h 2011-03-24 04:35:25 UTC (rev 58060) @@ -49,6 +49,7 @@ #endif extern int azy_log_dom; +extern int azy_rpc_log_dom; #define DBG(...) EINA_LOG_DOM_DBG(azy_log_dom, __VA_ARGS__) #define INFO(...) EINA_LOG_DOM_INFO(azy_log_dom, __VA_ARGS__) @@ -56,6 +57,12 @@ #define ERR(...) EINA_LOG_DOM_ERR(azy_log_dom, __VA_ARGS__) #define CRI(...) EINA_LOG_DOM_CRIT(azy_log_dom, __VA_ARGS__) +#define RPC_DBG(...) EINA_LOG_DOM_DBG(azy_rpc_log_dom, __VA_ARGS__) +#define RPC_INFO(...) EINA_LOG_DOM_INFO(azy_rpc_log_dom, __VA_ARGS__) +#define RPC_WARN(...) EINA_LOG_DOM_WARN(azy_rpc_log_dom, __VA_ARGS__) +#define RPC_ERR(...) EINA_LOG_DOM_ERR(azy_rpc_log_dom, __VA_ARGS__) +#define RPC_CRI(...) EINA_LOG_DOM_CRIT(azy_rpc_log_dom, __VA_ARGS__) + #if !defined(strdupa) # define strdupa(str) strcpy(alloca(strlen(str) + 1), str) #endif Modified: trunk/PROTO/azy/src/lib/azy_client_events.c =================================================================== --- trunk/PROTO/azy/src/lib/azy_client_events.c 2011-03-24 04:15:41 UTC (rev 58059) +++ trunk/PROTO/azy/src/lib/azy_client_events.c 2011-03-24 04:35:25 UTC (rev 58060) @@ -181,11 +181,12 @@ DBG("(hd=%p, client=%p, net=%p)", hd, hd->client, hd->recv); client = hd->client; -#ifdef ISCOMFITOR - char buf[64]; - snprintf(buf, sizeof(buf), "RECEIVED:\n<<<<<<<<<<<<<\n%%.%llis\n<<<<<<<<<<<<<", hd->recv->size); - INFO(buf, hd->recv->buffer); -#endif + if (azy_rpc_log_dom >= 0) + { + char buf[64]; + snprintf(buf, sizeof(buf), "RECEIVED:\n<<<<<<<<<<<<<\n%%.%llis\n<<<<<<<<<<<<<", hd->recv->size); + RPC_INFO(buf, hd->recv->buffer); + } /* handle HTTP GET request */ if (!hd->method) return _azy_client_handler_get(hd); INFO("Running RPC for %s", hd->method); @@ -369,15 +370,6 @@ DBG("(hd=%p, method='%s', ev=%p, data=%p)", hd, (hd) ? hd->method : NULL, ev, (ev) ? ev->data : NULL); DBG("(client=%p, server->client=%p)", hd->client, (ev) ? ecore_con_server_data_get(ev->server) : NULL); -#ifdef ISCOMFITOR - if (data) - { - char buf[64]; - snprintf(buf, sizeof(buf), "RECEIVED:\n<<<<<<<<<<<<<\n%%.%is\n<<<<<<<<<<<<<", len); - INFO(buf, data); - } -#endif - client = hd->client; if (!hd->recv) Modified: trunk/PROTO/azy/src/lib/azy_lib.c =================================================================== --- trunk/PROTO/azy/src/lib/azy_lib.c 2011-03-24 04:15:41 UTC (rev 58059) +++ trunk/PROTO/azy/src/lib/azy_lib.c 2011-03-24 04:35:25 UTC (rev 58060) @@ -79,6 +79,7 @@ #endif int azy_log_dom = -1; +int azy_rpc_log_dom = -1; static int azy_init_count_ = 0; static void @@ -144,7 +145,7 @@ * calls. * @return The number of times the function has been called, or -1 on failure */ -EAPI int +int azy_init(void) { if (++azy_init_count_ != 1) @@ -200,18 +201,29 @@ * @return The number of times azy_init has been called, or -1 if * all occurrences of azy have been shut down */ -EAPI int +int azy_shutdown(void) { if (--azy_init_count_ != 0) return azy_init_count_; eina_log_domain_unregister(azy_log_dom); + if (azy_rpc_log_dom != -1) + eina_log_domain_unregister(azy_rpc_log_dom); ecore_con_shutdown(); ecore_shutdown(); eina_shutdown(); azy_log_dom = -1; + azy_rpc_log_dom = -1; return azy_init_count_; } +void +azy_rpc_log_enable(void) +{ + EINA_SAFETY_ON_TRUE_RETURN(!azy_init_count_); + azy_rpc_log_dom = eina_log_domain_register("azy_rpc", EINA_COLOR_LIGHTCYAN); + if (azy_rpc_log_dom < 0) + ERR("Could not register 'azy_rpc' log domain!"); +} /** @} */ Modified: trunk/PROTO/azy/src/lib/azy_server_events.c =================================================================== --- trunk/PROTO/azy/src/lib/azy_server_events.c 2011-03-24 04:15:41 UTC (rev 58059) +++ trunk/PROTO/azy/src/lib/azy_server_events.c 2011-03-24 04:35:25 UTC (rev 58060) @@ -576,21 +576,6 @@ return; } -#ifdef ISCOMFITOR - { - char *d; - if (content) - d = azy_content_dump_string(content, 0); - else - d = (char *)data->data; - if (d) - { - DBG("%s\n", d); - free(d); - } - } -#endif - if (!net->http.res.http_code) { net->http.res.http_code = 200; @@ -620,13 +605,12 @@ else INFO("Sending HTTP: %s", client->net->http.res.http_msg); -#ifdef ISCOMFITOR - { - char buf[64]; - snprintf(buf, sizeof(buf), "SENDING:\n<<<<<<<<<<<<<\n%%.%is%%.%llis\n<<<<<<<<<<<<<", eina_strbuf_length_get(header), content->length); - INFO(buf, eina_strbuf_string_get(header), content->buffer); - } -#endif + if (azy_rpc_log_dom >= 0) + { + char buf[64]; + snprintf(buf, sizeof(buf), "SENDING:\n<<<<<<<<<<<<<\n%%.%is%%.%llis\n<<<<<<<<<<<<<", (int)eina_strbuf_length_get(header), content->length); + RPC_INFO(buf, eina_strbuf_string_get(header), content->buffer); + } EINA_SAFETY_ON_TRUE_GOTO(!ecore_con_client_send(net->conn, eina_strbuf_string_get(header), eina_strbuf_length_get(header)), error); INFO("Send [1/2] complete! %zu bytes queued for sending.", eina_strbuf_length_get(header)); @@ -791,11 +775,12 @@ cli = client; -#ifdef ISCOMFITOR - char buf[64]; - snprintf(buf, sizeof(buf), "RECEIVED:\n<<<<<<<<<<<<<\n%%.%is\n<<<<<<<<<<<<<", len); - INFO(buf, data); -#endif + if (azy_rpc_log_dom >= 0) + { + char buf[64]; + snprintf(buf, sizeof(buf), "RECEIVED:\n<<<<<<<<<<<<<\n%%.%is\n<<<<<<<<<<<<<", len); + RPC_INFO(buf, data); + } if (!client->net->size) { |