[clutter] debug: Group debug messages by timestamps



commit 42b933eeafc554e43c6e1579dcda6a4f8d7f39b4
Author: Emmanuele Bassi <ebassi linux intel com>
Date:   Thu Jun 7 11:51:33 2012 +0100

    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.

 clutter/clutter-main.c |   24 ++++++++++++++++++++++--
 1 files changed, 22 insertions(+), 2 deletions(-)
---
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);
 



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]