[gtk+] gdk: Don't use g_print for debug output



commit 2801f3c8431c0516f56fa8acb86f51f41b515602
Author: Matthias Clasen <mclasen redhat com>
Date:   Sun Feb 28 15:39:05 2016 -0500

    gdk: Don't use g_print for debug output
    
    The g_print documentation explicitly says not to do this, since
    g_print is meant to be redirected by applications. Instead use
    g_message for logging that can be triggered via GTK_DEBUG.

 gdk/gdkframeclock.c |   26 ++++++++++++++++----------
 gdk/gdkglcontext.c  |   26 +++++++++++++-------------
 2 files changed, 29 insertions(+), 23 deletions(-)
---
diff --git a/gdk/gdkframeclock.c b/gdk/gdkframeclock.c
index 3cf49ca..9399ab9 100644
--- a/gdk/gdkframeclock.c
+++ b/gdk/gdkframeclock.c
@@ -493,6 +493,8 @@ void
 _gdk_frame_clock_debug_print_timings (GdkFrameClock   *clock,
                                       GdkFrameTimings *timings)
 {
+  GString *str;
+
   gint64 previous_frame_time = 0;
   GdkFrameTimings *previous_timings = gdk_frame_clock_get_timings (clock,
                                                                    timings->frame_counter - 1);
@@ -500,25 +502,29 @@ _gdk_frame_clock_debug_print_timings (GdkFrameClock   *clock,
   if (previous_timings != NULL)
     previous_frame_time = previous_timings->frame_time;
 
-  g_print ("%5" G_GINT64_FORMAT ":", timings->frame_counter);
+  str = g_string_new ("");
+
+  g_string_append_printf (str, "%5" G_GINT64_FORMAT ":", timings->frame_counter);
   if (previous_frame_time != 0)
     {
-      g_print (" interval=%-4.1f", (timings->frame_time - previous_frame_time) / 1000.);
-      g_print (timings->slept_before ?  " (sleep)" : "        ");
+      g_string_append_printf (str, " interval=%-4.1f", (timings->frame_time - previous_frame_time) / 1000.);
+      g_string_append_printf (str, timings->slept_before ?  " (sleep)" : "        ");
     }
   if (timings->layout_start_time != 0)
-    g_print (" layout_start=%-4.1f", (timings->layout_start_time - timings->frame_time) / 1000.);
+    g_string_append_printf (str, " layout_start=%-4.1f", (timings->layout_start_time - timings->frame_time) 
/ 1000.);
   if (timings->paint_start_time != 0)
-    g_print (" paint_start=%-4.1f", (timings->paint_start_time - timings->frame_time) / 1000.);
+    g_string_append_printf (str, " paint_start=%-4.1f", (timings->paint_start_time - timings->frame_time) / 
1000.);
   if (timings->frame_end_time != 0)
-    g_print (" frame_end=%-4.1f", (timings->frame_end_time - timings->frame_time) / 1000.);
+    g_string_append_printf (str, " frame_end=%-4.1f", (timings->frame_end_time - timings->frame_time) / 
1000.);
   if (timings->presentation_time != 0)
-    g_print (" present=%-4.1f", (timings->presentation_time - timings->frame_time) / 1000.);
+    g_string_append_printf (str, " present=%-4.1f", (timings->presentation_time - timings->frame_time) / 
1000.);
   if (timings->predicted_presentation_time != 0)
-    g_print (" predicted=%-4.1f", (timings->predicted_presentation_time - timings->frame_time) / 1000.);
+    g_string_append_printf (str, " predicted=%-4.1f", (timings->predicted_presentation_time - 
timings->frame_time) / 1000.);
   if (timings->refresh_interval != 0)
-    g_print (" refresh_interval=%-4.1f", timings->refresh_interval / 1000.);
-  g_print ("\n");
+    g_string_append_printf (str, " refresh_interval=%-4.1f", timings->refresh_interval / 1000.);
+
+  g_message ("%s", str->str);
+  g_string_free (str, TRUE);
 }
 #endif /* G_ENABLE_DEBUG */
 
diff --git a/gdk/gdkglcontext.c b/gdk/gdkglcontext.c
index 06cd019..00a33eb 100644
--- a/gdk/gdkglcontext.c
+++ b/gdk/gdkglcontext.c
@@ -662,19 +662,19 @@ gdk_gl_context_check_extensions (GdkGLContext *context)
     g_warning ("GL implementation doesn't support any form of non-power-of-two textures");
 
   GDK_NOTE (OPENGL,
-            g_print ("OpenGL version: %d.%d\n"
-                     "Extensions checked:\n"
-                     " - GL_ARB_texture_non_power_of_two: %s\n"
-                     " - GL_ARB_texture_rectangle: %s\n"
-                     " - GL_EXT_framebuffer_blit: %s\n"
-                     " - GL_GREMEDY_frame_terminator: %s\n"
-                     "Using texture rectangle: %s\n",
-                     priv->gl_version / 10, priv->gl_version % 10,
-                     has_npot ? "yes" : "no",
-                     has_texture_rectangle ? "yes" : "no",
-                     priv->has_gl_framebuffer_blit ? "yes" : "no",
-                     priv->has_frame_terminator ? "yes" : "no",
-                     priv->use_texture_rectangle ? "yes" : "no"));
+            g_message ("OpenGL version: %d.%d\n"
+                       "Extensions checked:\n"
+                       " - GL_ARB_texture_non_power_of_two: %s\n"
+                       " - GL_ARB_texture_rectangle: %s\n"
+                       " - GL_EXT_framebuffer_blit: %s\n"
+                       " - GL_GREMEDY_frame_terminator: %s\n"
+                       "Using texture rectangle: %s",
+                       priv->gl_version / 10, priv->gl_version % 10,
+                       has_npot ? "yes" : "no",
+                       has_texture_rectangle ? "yes" : "no",
+                       priv->has_gl_framebuffer_blit ? "yes" : "no",
+                       priv->has_frame_terminator ? "yes" : "no",
+                       priv->use_texture_rectangle ? "yes" : "no"));
 
   priv->extensions_checked = TRUE;
 }


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