From 32e9b0cd8289b537c1877fcdd1e63278d6445ced Mon Sep 17 00:00:00 2001 From: Gwanglim Lee Date: Wed, 5 Aug 2015 15:06:22 +0900 Subject: [PATCH] e_log: added ELOG and ELOGF macros to support formatted log message Change-Id: I55929316156846d3d51d5188e0bdcdfcf02b1d81 --- src/bin/e_client.c | 4 ++++ src/bin/e_comp_wl.c | 67 ++++++++++++++++++++++++++++++++++++++++++++++++++++- src/bin/e_log.c | 5 ++-- src/bin/e_log.h | 34 +++++++++++++++++++++++++++ src/bin/e_pixmap.c | 4 ++++ 5 files changed, 111 insertions(+), 3 deletions(-) diff --git a/src/bin/e_client.c b/src/bin/e_client.c index 5370809..b5106d7 100644 --- a/src/bin/e_client.c +++ b/src/bin/e_client.c @@ -544,6 +544,7 @@ _e_client_free(E_Client *ec) e_hints_client_list_set(); evas_object_del(ec->frame); E_OBJECT(ec)->references--; + ELOG("CLIENT FREE", ec->pixmap, ec); free(ec); } @@ -615,6 +616,8 @@ _e_client_del(E_Client *ec) if ((!ec->new_client) && (!stopping)) _e_client_event_simple(ec, E_EVENT_CLIENT_REMOVE); + ELOG("CLIENT DEL", ec->pixmap, ec); + if (ec->parent) { ec->parent->transients = eina_list_remove(ec->parent->transients, ec); @@ -2732,6 +2735,7 @@ e_client_new(E_Comp *c EINA_UNUSED, E_Pixmap *cp, int first_map, int internal) e_comp->clients = eina_list_append(e_comp->clients, ec); eina_hash_add(clients_hash, &ec->pixmap, ec); + ELOG("CLIENT ADD", ec->pixmap, ec); _e_client_event_simple(ec, E_EVENT_CLIENT_ADD); e_comp_object_client_add(ec); if (ec->frame) diff --git a/src/bin/e_comp_wl.c b/src/bin/e_comp_wl.c index c95131a..fb9e2db 100644 --- a/src/bin/e_comp_wl.c +++ b/src/bin/e_comp_wl.c @@ -2033,10 +2033,61 @@ static const struct wl_compositor_interface _e_comp_interface = }; static void +_e_comp_wl_pname_print(pid_t pid) +{ + FILE *h; + char proc[512], pname[512]; + size_t len; + + sprintf(proc, "/proc/%d/cmdline", pid); + + h = fopen(proc, "r"); + if (!h) return; + + len = fread(pname, sizeof(char), 512, h); + if (len > 0) + { + if ('\n' == pname[len - 1]) + pname[len - 1] = '\0'; + } + + fclose(h); + + ELOGF("COMP", " |%s", NULL, NULL, pname); +} + + +static void +_e_comp_wl_compositor_cb_unbind(struct wl_resource *res_comp) +{ + struct wl_client *client; + pid_t pid = 0; + uid_t uid = 0; + gid_t gid = 0; + + client = wl_resource_get_client(res_comp); + if (client) + wl_client_get_credentials(client, + &pid, + &uid, + &gid); + + ELOGF("COMP", + "UNBIND |res_comp:0x%08x|client:0x%08x|%d|%d|%d", + NULL, NULL, + (unsigned int)res_comp, + (unsigned int)client, + pid, uid, gid); +} + +static void _e_comp_wl_compositor_cb_bind(struct wl_client *client, void *data, uint32_t version, uint32_t id) { E_Comp *comp; struct wl_resource *res; + pid_t pid = 0; + uid_t uid = 0; + gid_t gid = 0; if (!(comp = data)) return; @@ -2049,7 +2100,21 @@ _e_comp_wl_compositor_cb_bind(struct wl_client *client, void *data, uint32_t ver return; } - wl_resource_set_implementation(res, &_e_comp_interface, comp, NULL); + wl_resource_set_implementation(res, + &_e_comp_interface, + comp, + _e_comp_wl_compositor_cb_unbind); + + wl_client_get_credentials(client, &pid, &uid, &gid); + + ELOGF("COMP", + "BIND |res_comp:0x%08x|client:0x%08x|%d|%d|%d", + NULL, NULL, + (unsigned int)res, + (unsigned int)client, + pid, uid, gid); + + _e_comp_wl_pname_print(pid); } static void diff --git a/src/bin/e_log.c b/src/bin/e_log.c index 56e5500..40519eb 100644 --- a/src/bin/e_log.c +++ b/src/bin/e_log.c @@ -17,7 +17,7 @@ _e_log_cb(const Eina_Log_Domain *d, Eina_Log_Level level, const char *file, cons color = eina_log_level_color_get(level); fprintf(stdout, - "%s%s<" EINA_COLOR_RESET "%s%s>" EINA_COLOR_RESET "%s:%d" EINA_COLOR_RESET " ", + "%s%s<" EINA_COLOR_RESET "%s%s>" EINA_COLOR_RESET "%30.30s:%04d" EINA_COLOR_RESET " ", color, _names[level > EINA_LOG_LEVEL_DBG ? EINA_LOG_LEVEL_DBG : level], d->domain_str, color, file, line); vfprintf(stdout, fmt, args); @@ -29,7 +29,8 @@ e_log_init(void) { e_log_dom = eina_log_domain_register("e", EINA_COLOR_WHITE); eina_log_print_cb_set(_e_log_cb, NULL); - return e_log_dom != -1; + eina_log_domain_level_set("e", 3); + return 1; } EINTERN int diff --git a/src/bin/e_log.h b/src/bin/e_log.h index 4100780..12dd10d 100644 --- a/src/bin/e_log.h +++ b/src/bin/e_log.h @@ -17,6 +17,36 @@ #define ERR(...) EINA_LOG_DOM_ERR(e_log_dom, __VA_ARGS__) #define CRI(...) EINA_LOG_DOM_CRIT(e_log_dom, __VA_ARGS__) +#define ELOG(t, cp, ec) \ + do \ + { \ + if ((!cp) && (!ec)) \ + INF("EWL|%20.20s| | |", \ + (t)); \ + else \ + INF("EWL|%20.20s|cp:0x%08x|ec:0x%08x|", \ + (t), \ + (unsigned int)(cp), \ + (unsigned int)(ec)); \ + } \ + while (0) + +#define ELOGF(t, f, cp, ec, x...) \ + do \ + { \ + if ((!cp) && (!ec)) \ + INF("EWL|%20.20s| | |"f, \ + (t), ##x); \ + else \ + INF("EWL|%20.20s|cp:0x%08x|ec:0x%08x|"f, \ + (t), \ + (unsigned int)(cp), \ + (unsigned int)(ec), \ + ##x); \ + } \ + while (0) + + EINTERN extern int e_log_dom; EINTERN int e_log_init(void); @@ -27,11 +57,15 @@ EINTERN int e_log_shutdown(void); #undef WRN #undef ERR #undef CRI +#undef ELOG +#undef ELOGF #define DBG(...) printf(__VA_ARGS__); putc('\n', stdout) #define INF(...) printf(__VA_ARGS__); putc('\n', stdout) #define WRN(...) printf(__VA_ARGS__); putc('\n', stdout) #define ERR(...) printf(__VA_ARGS__); putc('\n', stdout) #define CRI(...) printf(__VA_ARGS__); putc('\n', stdout) +#define ELOG(...) ; +#define ELOGF(...) ; #endif #endif diff --git a/src/bin/e_pixmap.c b/src/bin/e_pixmap.c index 1853934..5e494ca 100644 --- a/src/bin/e_pixmap.c +++ b/src/bin/e_pixmap.c @@ -132,6 +132,7 @@ _e_pixmap_clear(E_Pixmap *cp, Eina_Bool cache) } e_comp_wl_buffer_reference(&cp->buffer_ref, NULL); + ELOG("PIXMAP CLEAR", cp, cp->client); (void)cache; #endif @@ -184,6 +185,7 @@ _e_pixmap_free(E_Pixmap *cp) } #endif _e_pixmap_clear(cp, 1); + ELOG("PIXMAP FREE", cp, cp->client); free(cp); } @@ -245,6 +247,7 @@ e_pixmap_free(E_Pixmap *cp) { if (!cp) return 0; if (--cp->refcount) return cp->refcount; + ELOG("PIXMAP DEL", cp, cp->client); _e_pixmap_hook_call(E_PIXMAP_HOOK_DEL, cp); e_pixmap_image_clear(cp, EINA_FALSE); if (cp->parent) eina_hash_set(pixmaps[cp->type], &cp->parent, NULL); @@ -351,6 +354,7 @@ e_pixmap_new(E_Pixmap_Type type, ...) cp->res_id = res_id; eina_hash_add(res_ids, &res_id, cp); res_id++; + ELOG("PIXMAP NEW", cp, cp->client); #endif break; } -- 2.7.4