[nautilus-actions: 21/30] Review log handlers
- From: Pierre Wieser <pwieser src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [nautilus-actions: 21/30] Review log handlers
- Date: Sat, 21 Nov 2009 18:03:02 +0000 (UTC)
commit e97568a91b817769c85b7f00944e95e561c43fa7
Author: Pierre Wieser <pwieser trychlos org>
Date: Fri Nov 20 23:56:45 2009 +0100
Review log handlers
ChangeLog | 12 ++++++++
TODO | 3 +-
nautilus-actions/io-provider-gconf/nagp-module.c | 2 +-
nautilus-actions/nact/nact-main.c | 6 ++--
nautilus-actions/plugin/nautilus-module.c | 31 +++++++++++----------
nautilus-actions/utils/console-utils.c | 8 +++---
6 files changed, 38 insertions(+), 24 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index ff4c8c8..4c34d6d 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,17 @@
2009-11-20 Pierre Wieser <pwieser trychlos org>
+ Review log handlers.
+
+ * nautilus-actions/io-provider-gconf/nagp-module.c
+ (na_api_module_init): standardize debug message.
+
+ * nautilus-actions/nact/nact-main.c:
+ Better name the static variable which holds the default handler.
+
+ * nautilus-actions/plugin/nautilus-module.c:
+ * nautilus-actions/utils/console-utils.c:
+ Simplify log handler management on NACT model.
+
* src/Makefile.am:
Update compilation order as io-provider-gconf plugin depends on
runtime.
diff --git a/TODO b/TODO
index 18eda9d..4f720ae 100644
--- a/TODO
+++ b/TODO
@@ -92,4 +92,5 @@
- na_pivot_get_item: should return NAObjectItem
-- review log handlers (cf. nact for a ref)
+- error message in syslog
+ [(null)] Unable to add monitor: Not supported
diff --git a/nautilus-actions/io-provider-gconf/nagp-module.c b/nautilus-actions/io-provider-gconf/nagp-module.c
index aa82bce..2b21cde 100644
--- a/nautilus-actions/io-provider-gconf/nagp-module.c
+++ b/nautilus-actions/io-provider-gconf/nagp-module.c
@@ -58,7 +58,7 @@ na_api_module_init( GTypeModule *module )
static const gchar *thisfn = "nagp_module_na_api_module_initialize";
static const gchar *name = "NagpGConfIOProvider";
- g_debug( "%s: module=%p, %s initializing...", thisfn, ( void * ) module, name );
+ g_debug( "%s: module=%p", thisfn, ( void * ) module );
g_type_module_set_name( module, name );
diff --git a/nautilus-actions/nact/nact-main.c b/nautilus-actions/nact/nact-main.c
index b70d103..a4f47a5 100644
--- a/nautilus-actions/nact/nact-main.c
+++ b/nautilus-actions/nact/nact-main.c
@@ -37,7 +37,7 @@
static void set_log_handler( void );
static void log_handler( const gchar *log_domain, GLogLevelFlags log_level, const gchar *message, gpointer user_data );
-static GLogFunc st_log_func = NULL;
+static GLogFunc st_default_log_func = NULL;
int
main( int argc, char *argv[] )
@@ -59,14 +59,14 @@ main( int argc, char *argv[] )
static void
set_log_handler( void )
{
- st_log_func = g_log_set_default_handler(( GLogFunc ) log_handler, NULL );
+ st_default_log_func = g_log_set_default_handler(( GLogFunc ) log_handler, NULL );
}
static void
log_handler( const gchar *log_domain, GLogLevelFlags log_level, const gchar *message, gpointer user_data )
{
#ifdef NA_MAINTAINER_MODE
- ( *st_log_func )( log_domain, log_level, message, user_data );
+ ( *st_default_log_func )( log_domain, log_level, message, user_data );
#else
/* do nothing */
#endif
diff --git a/nautilus-actions/plugin/nautilus-module.c b/nautilus-actions/plugin/nautilus-module.c
index abc873f..7a60cff 100644
--- a/nautilus-actions/plugin/nautilus-module.c
+++ b/nautilus-actions/plugin/nautilus-module.c
@@ -38,9 +38,10 @@
#include "nautilus-actions.h"
-static guint st_log_handler = 0;
+static void set_log_handler( void );
+static void log_handler( const gchar *log_domain, GLogLevelFlags log_level, const gchar *message, gpointer user_data );
-static void na_log_handler( const gchar *log_domain, GLogLevelFlags log_level, const gchar *message, gpointer user_data );
+static GLogFunc st_default_log_func = NULL;
/*
* A nautilus extension must implement three functions :
@@ -61,11 +62,7 @@ nautilus_module_initialize( GTypeModule *module )
syslog( LOG_USER | LOG_INFO, "%s initializing...", PACKAGE_STRING );
- if( !st_log_handler ){
- openlog( G_LOG_DOMAIN, LOG_PID, LOG_USER );
- st_log_handler = g_log_set_handler( NA_LOGDOMAIN_PLUGIN, G_LOG_LEVEL_DEBUG, na_log_handler, NULL );
- g_log_set_handler( NA_LOGDOMAIN_RUNTIME, G_LOG_LEVEL_DEBUG, na_log_handler, NULL );
- }
+ set_log_handler();
g_debug( "%s: module=%p", thisfn, ( void * ) module );
@@ -98,9 +95,9 @@ nautilus_module_shutdown( void )
* almost useless as the process is nonetheless terminating at this time
* but this is the art of coding...
*/
- if( st_log_handler ){
- g_log_remove_handler( G_LOG_DOMAIN, st_log_handler );
- st_log_handler = 0;
+ if( st_default_log_func ){
+ g_log_set_default_handler( st_default_log_func, NULL );
+ st_default_log_func = NULL;
}
}
@@ -112,13 +109,17 @@ nautilus_module_shutdown( void )
* For now, is always install when compiled in maintainer mode, never else
*/
static void
-na_log_handler( const gchar *log_domain,
- GLogLevelFlags log_level,
- const gchar *message,
- gpointer user_data )
+set_log_handler( void )
+{
+ st_default_log_func = g_log_set_default_handler(( GLogFunc ) log_handler, NULL );
+}
+
+static void
+log_handler( const gchar *log_domain, GLogLevelFlags log_level, const gchar *message, gpointer user_data )
{
#ifdef NA_MAINTAINER_MODE
- syslog( LOG_USER | LOG_DEBUG, "%s", message );
+ /*( *st_default_log_func )( log_domain, log_level, message, user_data );*/
+ syslog( LOG_USER | LOG_DEBUG, "[%s] %s", log_domain, message );
#else
/* do nothing */
#endif
diff --git a/nautilus-actions/utils/console-utils.c b/nautilus-actions/utils/console-utils.c
index 316920b..746bc1d 100644
--- a/nautilus-actions/utils/console-utils.c
+++ b/nautilus-actions/utils/console-utils.c
@@ -40,6 +40,8 @@
static void log_handler( const gchar *log_domain, GLogLevelFlags log_level, const gchar *message, gpointer user_data );
+static GLogFunc st_default_log_func = NULL;
+
/**
* console_init_log_handler:
*
@@ -49,9 +51,7 @@ static void log_handler( const gchar *log_domain, GLogLevelFlags log_level, cons
void
console_init_log_handler( void )
{
- g_log_set_handler( NA_LOGDOMAIN_PRIVATE, G_LOG_LEVEL_DEBUG, log_handler, NULL );
- g_log_set_handler( NA_LOGDOMAIN_RUNTIME, G_LOG_LEVEL_DEBUG, log_handler, NULL );
- g_log_set_handler( NA_LOGDOMAIN_UTILS, G_LOG_LEVEL_DEBUG, log_handler, NULL );
+ st_default_log_func = g_log_set_default_handler(( GLogFunc ) log_handler, NULL );
}
/**
@@ -86,7 +86,7 @@ static void
log_handler( const gchar *log_domain, GLogLevelFlags log_level, const gchar *message, gpointer user_data )
{
#ifdef NA_MAINTAINER_MODE
- g_log_default_handler( log_domain, log_level, message, user_data );
+ ( *st_default_log_func )( log_domain, log_level, message, user_data );
#else
/* do nothing */
#endif
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]