[gtk-vnc-devel] [patch] debug messages revisited



Hi, guys.

Here it's the rewriting of debug log messages.

- Now, debug framework is enabled by default in configure stage.
- Messages are only generated when the new function
vnc_display_enable_debug(TRUE) is called.
- If the app just wants to show the messages, it's enough to call that
function. If it wants to have more control of the messages, it can call
g_log_set_handler("gtk-vnc",G_LOG_LEVEL_DEBUG,handler_function,data).

Comments?
-- 
Jonh Wendell
www.bani.com.br

diff -r 15d01d93a5fe configure.ac
--- a/configure.ac	Tue Mar 25 17:09:36 2008 -0300
+++ b/configure.ac	Thu Mar 27 17:08:56 2008 -0300
@@ -196,8 +196,15 @@ if test "$WITH_PYTHON" = "yes"; then
   fi
 fi
 
-dnl --enable-debug=(yes|no)
-AC_ARG_ENABLE(debug, [  --enable-debug=[no/yes] turn on debugging [default=no]],,enable_debug=no)
+dnl Debugging stuff
+AC_ARG_ENABLE(debug, [  --enable-debug=[yes/no] turn on debugging framework [default=yes]],
+[case "${enableval}" in
+  yes) enable_debug=yes ;;
+  no)  enable_debug=no ;;
+  *) AC_MSG_ERROR(bad value ${enableval} for --enable-debug) ;;
+esac], 
+[enable_debug=yes]) dnl Default value
+
 if test "$enable_debug" = "yes"; then
   DEBUG_CFLAGS="-DENABLE_DEBUG"
 else
@@ -251,6 +258,6 @@ Configure summary:
 	Python biding ..............:  ${WITH_PYTHON}
 	Install example programs ...:  ${WITH_EXAMPLES}
 	Browser plugin .............:  ${enable_plugin}
-	DEBUG messages..............:  ${enable_debug}
+	DEBUG framework.............:  ${enable_debug}
 	Scaling support.............:  ${with_scaling}
 "
diff -r 15d01d93a5fe src/Makefile.am
--- a/src/Makefile.am	Tue Mar 25 17:09:36 2008 -0300
+++ b/src/Makefile.am	Thu Mar 27 17:08:56 2008 -0300
@@ -8,7 +8,7 @@ libgtk_vnc_1_0_la_CFLAGS = @GTK_CFLAGS@ 
 libgtk_vnc_1_0_la_CFLAGS = @GTK_CFLAGS@ @GTKGLEXT_CFLAGS@ @GNUTLS_CFLAGS@ \
 			   @GTHREAD_CFLAGS@ @WARNING_CFLAGS@ \
 			   -DSYSCONFDIR=\""$(sysconfdir)"\" \
-                           @DEBUG_CFLAGS@
+                           @DEBUG_CFLAGS@ -DG_LOG_DOMAIN=\"gtk-vnc\"
 libgtk_vnc_1_0_la_LDFLAGS = -Wl,--version-script=$(srcdir)/libgtk-vnc_sym.version \
                             -version-info 0:1:0
 
@@ -22,7 +22,7 @@ libgtk_vnc_1_0_la_SOURCES = blt.h blt1.h
 	vncdisplay.h vncdisplay.c \
         vncmarshal.h vncmarshal.c \
 	x_keymap.h x_keymap.c vnc_keycodes.h \
-	utils.h
+	utils.h utils.c
 
 if WITH_UCONTEXT
 libgtk_vnc_1_0_la_SOURCES += continuation.h continuation.c coroutine_ucontext.c
diff -r 15d01d93a5fe src/libgtk-vnc_sym.version
--- a/src/libgtk-vnc_sym.version	Tue Mar 25 17:09:36 2008 -0300
+++ b/src/libgtk-vnc_sym.version	Thu Mar 27 17:08:56 2008 -0300
@@ -45,6 +45,8 @@
     vnc_display_force_grab;
     vnc_display_is_pointer_absolute;
 
+    vnc_display_enable_debug;
+
   local:
       *;
 };
diff -r 15d01d93a5fe src/utils.c
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/utils.c	Thu Mar 27 17:08:56 2008 -0300
@@ -0,0 +1,26 @@
+/*
+ * Copyright (C) 2006  Anthony Liguori <anthony codemonkey ws>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 2 or
+ * later as published by the Free Software Foundation.
+ *
+ *  GTK VNC Widget
+ */
+
+#include "utils.h"
+
+#ifdef ENABLE_DEBUG
+
+gboolean debug_enabled = FALSE;
+
+void vnc_display_enable_debug (gboolean enabled)
+{
+	debug_enabled = enabled;
+}
+
+#else
+
+void vnc_display_enable_debug (gboolean enabled G_GNUC_UNUSED) {}
+
+#endif
diff -r 15d01d93a5fe src/utils.h
--- a/src/utils.h	Tue Mar 25 17:09:36 2008 -0300
+++ b/src/utils.h	Thu Mar 27 17:08:56 2008 -0300
@@ -11,8 +11,13 @@
 #ifndef _UTILS_H
 #define _UTILS_H
 
+#include <glib.h>
+
 #ifdef ENABLE_DEBUG
-#define GVNC_DEBUG(fmt, ...) do { fprintf(stderr, fmt, ## __VA_ARGS__); } while (0)
+
+extern gboolean debug_enabled;
+
+#define GVNC_DEBUG(fmt, ...) do { if (G_UNLIKELY(debug_enabled)) g_debug(fmt, ## __VA_ARGS__); } while (0)
 #else
 #define GVNC_DEBUG(fmt, ...) do { } while (0)
 #endif
diff -r 15d01d93a5fe src/vncdisplay.h
--- a/src/vncdisplay.h	Tue Mar 25 17:09:36 2008 -0300
+++ b/src/vncdisplay.h	Thu Mar 27 17:08:56 2008 -0300
@@ -120,6 +120,8 @@ void		vnc_display_force_grab(VncDisplay 
 
 gboolean	vnc_display_is_pointer_absolute(VncDisplay *obj);
 
+void		vnc_display_enable_debug(gboolean enabled);
+
 G_END_DECLS
 
 #endif


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