diff options
author | Tiago Vignatti <tiago.vignatti@intel.com> | 2011-07-14 18:56:40 +0300 |
---|---|---|
committer | Kristian Høgsberg <krh@bitplanet.net> | 2011-07-15 15:04:50 -0400 |
commit | a9ef785cf83731b82334b22894dd01ee6ada66c8 (patch) | |
tree | 86574257910cfea41728958c33c13295daf301f1 | |
parent | 98da0a7b982310992e3af1b376c4b05ea4f2c71a (diff) |
debug: add timestamps when logging
Signed-off-by: Tiago Vignatti <tiago.vignatti@intel.com>
-rw-r--r-- | wayland/connection.c | 16 | ||||
-rw-r--r-- | wayland/connection.h | 2 | ||||
-rw-r--r-- | wayland/wayland-client.c | 9 | ||||
-rw-r--r-- | wayland/wayland-server.c | 9 |
4 files changed, 23 insertions, 13 deletions
diff --git a/wayland/connection.c b/wayland/connection.c index 0f2051a..4f6a845 100644 --- a/wayland/connection.c +++ b/wayland/connection.c @@ -34,6 +34,7 @@ #include <unistd.h> #include <sys/types.h> #include <sys/socket.h> +#include <time.h> #include "wayland-util.h" #include "connection.h" @@ -684,12 +685,23 @@ wl_closure_send(struct wl_closure *closure, struct wl_connection *connection) } void -wl_closure_print(struct wl_closure *closure, struct wl_object *target) +wl_closure_print(struct wl_closure *closure, struct wl_object *target, int send) { union wl_value *value; + char buffer[4] = "\0"; int i; + struct timespec tp; + unsigned int time; - fprintf(stderr, "%s@%d.%s(", + if (send) + sprintf(buffer, " -> "); + + clock_gettime(CLOCK_REALTIME, &tp); + time = (tp.tv_sec * 1000000L) + (tp.tv_nsec / 1000); + + fprintf(stderr, "[%10.3f] %s%s@%d.%s(", + time / 1000.0, + buffer, target->interface->name, target->id, closure->message->name); diff --git a/wayland/connection.h b/wayland/connection.h index 413977d..5f4588b 100644 --- a/wayland/connection.h +++ b/wayland/connection.h @@ -61,7 +61,7 @@ wl_closure_invoke(struct wl_closure *closure, void wl_closure_send(struct wl_closure *closure, struct wl_connection *connection); void -wl_closure_print(struct wl_closure *closure, struct wl_object *target); +wl_closure_print(struct wl_closure *closure, struct wl_object *target, int send); void wl_closure_destroy(struct wl_closure *closure); diff --git a/wayland/wayland-client.c b/wayland/wayland-client.c index e8266e1..ce27a90 100644 --- a/wayland/wayland-client.c +++ b/wayland/wayland-client.c @@ -24,6 +24,7 @@ #include <stdint.h> #include <stddef.h> #include <stdio.h> +#include <stdbool.h> #include <errno.h> #include <string.h> #include <unistd.h> @@ -201,10 +202,8 @@ wl_proxy_marshal(struct wl_proxy *proxy, uint32_t opcode, ...) wl_closure_send(closure, proxy->display->connection); - if (wl_debug) { - fprintf(stderr, " -> "); - wl_closure_print(closure, &proxy->object); - } + if (wl_debug) + wl_closure_print(closure, &proxy->object, true); wl_closure_destroy(closure); } @@ -523,7 +522,7 @@ handle_event(struct wl_display *display, size, display->objects, message); if (wl_debug) - wl_closure_print(closure, &proxy->object); + wl_closure_print(closure, &proxy->object, false); wl_closure_invoke(closure, &proxy->object, proxy->object.implementation[opcode], diff --git a/wayland/wayland-server.c b/wayland/wayland-server.c index 176859b..d4fdfc7 100644 --- a/wayland/wayland-server.c +++ b/wayland/wayland-server.c @@ -27,6 +27,7 @@ #include <stddef.h> #include <stdio.h> #include <stdarg.h> +#include <stdbool.h> #include <errno.h> #include <string.h> #include <unistd.h> @@ -108,10 +109,8 @@ wl_client_post_event(struct wl_client *client, struct wl_object *sender, wl_closure_send(closure, client->connection); - if (wl_debug) { - fprintf(stderr, " -> "); - wl_closure_print(closure, sender); - } + if (wl_debug) + wl_closure_print(closure, sender, true); wl_closure_destroy(closure); } @@ -202,7 +201,7 @@ wl_client_connection_data(int fd, uint32_t mask, void *data) if (wl_debug) - wl_closure_print(closure, object); + wl_closure_print(closure, object, false); wl_closure_invoke(closure, object, object->implementation[opcode], client); |