g_log() accelerated by 'captive_debug_messages_disabled' slave global flag.
authorshort <>
Tue, 28 Oct 2003 16:39:47 +0000 (16:39 +0000)
committershort <>
Tue, 28 Oct 2003 16:39:47 +0000 (16:39 +0000)
src/libcaptive/client/init.c
src/libcaptive/include/captive/config2.h

index f7344eb..a2459e4 100644 (file)
@@ -74,14 +74,7 @@ static TOP_LEVEL_IRP TopLevelIrp;    /* TODO:thread */
 void *_local_unwind2_addr;
 
 
-/* Acceleration hack for ntoskrnl/dbg/print.c/DbgPrint() */
-gboolean captive_get_debug_messages(void)
-{
-       g_return_val_if_fail(captive_options!=NULL,TRUE);
-
-       return captive_options->debug_messages;
-}
-
+gboolean captive_debug_messages_disabled=FALSE;
 
 static gboolean captive_w32_init(void)
 {
@@ -257,6 +250,10 @@ void captive_log_init(const struct captive_options *captive_options)
 {
        g_return_if_fail(captive_options!=NULL);
 
+       /* FIXME: Fix sharing of different 'debug_messages' for various sandboxes. */
+       captive_debug_messages_disabled=!captive_options->debug_messages;
+
+       /* FIXME: Fix sharing of different 'debug_messages' for various sandboxes. */
        if (!captive_options->debug_messages) {
                /* FIXME: Save handler_id and destroy it in captive_vfs_close(). */
                g_log_set_handler(
index c2d7fed..d90780f 100644 (file)
 #endif
 
 
+/* g_log() and g_logv() acceleration */
+#ifdef LIBCAPTIVE
+#include <glib/gmessages.h>    /* for g_log() */
+#include <glib/gtypes.h>       /* for 'gboolean' */
+extern gboolean captive_debug_messages_disabled;
+#define g_log(log_domain,log_level,format,args...) ({ \
+               GLogLevelFlags _captive_g_log_log_level=(log_level); \
+               if ((_captive_g_log_log_level&~(G_LOG_LEVEL_MESSAGE|G_LOG_LEVEL_INFO|G_LOG_LEVEL_DEBUG)) \
+                               || !captive_debug_messages_disabled) \
+                       g_log((log_domain),_captive_g_log_log_level,(format) , ## args); \
+               })
+#define g_logv(log_domain,log_level,format,args) ({ \
+               GLogLevelFlags _captive_g_logv_log_level=(log_level); \
+               if ((_captive_g_logv_log_level&~(G_LOG_LEVEL_MESSAGE|G_LOG_LEVEL_INFO|G_LOG_LEVEL_DEBUG)) \
+                               || !captive_debug_messages_disabled) \
+                       g_logv((log_domain),_captive_g_logv_log_level,(format),(args)); \
+               })
+#endif /* LIBCAPTIVE */
+
+
 #endif /* _CAPTIVE_CONFIG2_H */