From: Emmanuele Bassi Date: Thu, 7 Jun 2012 10:51:33 +0000 (+0100) Subject: debug: Group debug messages by timestamps X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=42b933eeafc554e43c6e1579dcda6a4f8d7f39b4;p=profile%2Fivi%2Fclutter.git debug: Group debug messages by timestamps Instead of showing the full timestamp for debugging messages that happen within a second, showing the delta from the previous full timestamp can be more useful when debugging; this allows immediately seeing the time difference, instead of doing the math in our heads. --- diff --git a/clutter/clutter-main.c b/clutter/clutter-main.c index 744301b..3069837 100644 --- a/clutter/clutter-main.c +++ b/clutter/clutter-main.c @@ -3850,10 +3850,30 @@ void _clutter_debug_messagev (const char *format, va_list var_args) { + static gint64 last_debug_stamp; gchar *stamp, *fmt; + gint64 cur_time, debug_stamp; + + cur_time = g_get_monotonic_time (); + + /* if the last debug message happened less than a second ago, just + * show the increments instead of the full timestamp + */ + if (last_debug_stamp == 0 || + cur_time - last_debug_stamp >= G_USEC_PER_SEC) + { + debug_stamp = cur_time; + last_debug_stamp = debug_stamp; + + stamp = g_strdup_printf ("[%16" G_GINT64_FORMAT "]", debug_stamp); + } + else + { + debug_stamp = cur_time - last_debug_stamp; + + stamp = g_strdup_printf ("[%+16" G_GINT64_FORMAT "]", debug_stamp); + } - stamp = g_strdup_printf ("[%16" G_GINT64_FORMAT "]", - g_get_monotonic_time ()); fmt = g_strconcat (stamp, ":", format, NULL); g_free (stamp);