From 2801f3c8431c0516f56fa8acb86f51f41b515602 Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Sun, 28 Feb 2016 15:39:05 -0500 Subject: 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 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-) (limited to 'gdk/gdkframeclock.c') diff --git a/gdk/gdkframeclock.c b/gdk/gdkframeclock.c index 3cf49ca65f..9399ab9f06 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 */ -- cgit v1.2.1