[gtk/debug-envvars-cleanup: 1/14] Introduce new debug macros
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk/debug-envvars-cleanup: 1/14] Introduce new debug macros
- Date: Fri, 23 Sep 2022 22:52:24 +0000 (UTC)
commit 10255eee722634d5b85df757687d9fe7a4ca2b91
Author: Matthias Clasen <mclasen redhat com>
Date: Thu Sep 22 20:47:09 2022 -0400
Introduce new debug macros
Introduce GDK_DISPLAY_DEBUG() and GDK_DEBUG() and
the helper function gdk_debug_message(). This is
meant to clean up the mess of our current debug
statements which wildly mix g_message, g_print
and g_printerr.
gdk/gdk.c | 1 +
gdk/gdkdebug.h | 9 +++++++++
2 files changed, 10 insertions(+)
---
diff --git a/gdk/gdk.c b/gdk/gdk.c
index 2c145a0898..babb4298ac 100644
--- a/gdk/gdk.c
+++ b/gdk/gdk.c
@@ -34,6 +34,7 @@
#include "gdkglcontextprivate.h"
#include "gdkintl.h"
#include "gdk-private.h"
+#include <glib/gprintf.h>
#include <string.h>
#include <stdlib.h>
diff --git a/gdk/gdkdebug.h b/gdk/gdkdebug.h
index 8b185bf3d3..45519a1b4d 100644
--- a/gdk/gdkdebug.h
+++ b/gdk/gdkdebug.h
@@ -21,6 +21,7 @@
#include <glib.h>
#include "gdktypes.h"
+#include <glib/gstdio.h>
G_BEGIN_DECLS
@@ -58,6 +59,8 @@ GdkDebugFlags gdk_display_get_debug_flags (GdkDisplay *display);
void gdk_display_set_debug_flags (GdkDisplay *display,
GdkDebugFlags flags);
+#define gdk_debug_message(format, ...) g_fprintf (stderr, format "\n", ##__VA_ARGS__)
+
#ifdef G_ENABLE_DEBUG
#define GDK_DISPLAY_DEBUG_CHECK(display,type) \
@@ -66,14 +69,20 @@ void gdk_display_set_debug_flags (GdkDisplay *display,
if (GDK_DISPLAY_DEBUG_CHECK (display,type)) \
{ action; }; } G_STMT_END
+#define GDK_DISPLAY_DEBUG(display,type,...) \
+ if (GDK_DISPLAY_DEBUG_CHECK (display,type)) \
+ gdk_debug_message (__VA_ARGS__); \
+
#else /* !G_ENABLE_DEBUG */
#define GDK_DISPLAY_DEBUG_CHECK(display,type) 0
#define GDK_DISPLAY_NOTE(display,type,action)
+#define GDK_DISPLAY_DEBUG(display,type,...)
#endif /* G_ENABLE_DEBUG */
#define GDK_DEBUG_CHECK(type) GDK_DISPLAY_DEBUG_CHECK (NULL,type)
#define GDK_NOTE(type,action) GDK_DISPLAY_NOTE (NULL,type,action)
+#define GDK_DEBUG(type,...) GDK_DISPLAY_DEBUG (NULL,type,__VA_ARGS__)
#endif
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]