[nautilus-actions: 22/30] Review Nautilus plugin log handler



commit 3a6505576c17ba1f9f35164004ba378df4434f0b
Author: Pierre Wieser <pwieser trychlos org>
Date:   Sat Nov 21 00:19:57 2009 +0100

    Review Nautilus plugin log handler
    
    We used to install a log handler for each and every log domain used in Nautilus-Actions;
    this led to a fastidious enumeration! Instead we install now a default handler which
    will receive _all_ debug messages, from all code in Nautilus process.

 TODO                                      |    3 ---
 nautilus-actions/plugin/nautilus-module.c |   20 +++++++++++++++++++-
 2 files changed, 19 insertions(+), 4 deletions(-)
---
diff --git a/TODO b/TODO
index 4f720ae..9c16e4a 100644
--- a/TODO
+++ b/TODO
@@ -91,6 +91,3 @@
 - NACT: unable to really delete an action imported with schemas
 
 - na_pivot_get_item: should return NAObjectItem
-
-- error message in syslog
-  [(null)] Unable to add monitor: Not supported
diff --git a/nautilus-actions/plugin/nautilus-module.c b/nautilus-actions/plugin/nautilus-module.c
index 7a60cff..beb951b 100644
--- a/nautilus-actions/plugin/nautilus-module.c
+++ b/nautilus-actions/plugin/nautilus-module.c
@@ -32,6 +32,7 @@
 #include <config.h>
 #endif
 
+#include <string.h>
 #include <syslog.h>
 
 #include <libnautilus-extension/nautilus-extension-types.h>
@@ -114,13 +115,30 @@ set_log_handler( void )
 	st_default_log_func = g_log_set_default_handler(( GLogFunc ) log_handler, NULL );
 }
 
+/*
+ * we used to install a log handler for each and every log domain used
+ * in Nautilus-Actions ; this led to a fastidious enumeration
+ * instead we install a default log handler which will receive all
+ * debug messages, i.e. not only from N-A, but also from other code
+ * in the Nautilus process
+ */
 static void
 log_handler( const gchar *log_domain, GLogLevelFlags log_level, const gchar *message, gpointer user_data )
 {
+	gchar *tmp;
+
+	tmp = g_strdup( "" );
+	if( log_domain && strlen( log_domain )){
+		g_free( tmp );
+		tmp = g_strdup_printf( "[%s] ", log_domain );
+	}
+
 #ifdef NA_MAINTAINER_MODE
 	/*( *st_default_log_func )( log_domain, log_level, message, user_data );*/
-	syslog( LOG_USER | LOG_DEBUG, "[%s] %s", log_domain, message );
+	syslog( LOG_USER | LOG_DEBUG, "%s%s", tmp, message );
 #else
 	/* do nothing */
 #endif
+
+	g_free( tmp );
 }



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