summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorDavid Zeuthen <davidz@redhat.com>2009-04-15 09:40:58 -0400
committerDavid Zeuthen <davidz@redhat.com>2009-04-15 09:40:58 -0400
commite98da9ff4af7ac297a0154e7ec29048ea6359bb9 (patch)
tree417639005646e3784ddccff15ac3dec34b8cca4d /src
parentf6c622352767cdd7ffe94b78f58749b9e76ba71a (diff)
downloadgnome-disk-utility-e98da9ff4af7ac297a0154e7ec29048ea6359bb9.tar.gz
gnome-disk-utility-e98da9ff4af7ac297a0154e7ec29048ea6359bb9.tar.xz
gnome-disk-utility-e98da9ff4af7ac297a0154e7ec29048ea6359bb9.zip
only spew debug if GDU_DEBUG is set to 1
Diffstat (limited to 'src')
-rw-r--r--src/gdu/gdu-device.c2
-rw-r--r--src/gdu/gdu-pool.c32
2 files changed, 33 insertions, 1 deletions
diff --git a/src/gdu/gdu-device.c b/src/gdu/gdu-device.c
index 78d774b..5a8fcd6 100644
--- a/src/gdu/gdu-device.c
+++ b/src/gdu/gdu-device.c
@@ -658,7 +658,7 @@ _gdu_device_new_from_object_path (GduPool *pool, const char *object_path)
if (!update_info (device))
goto error;
- g_print ("%s: %s\n", __FUNCTION__, device->priv->props->device_file);
+ g_debug ("_gdu_device_new_from_object_path: %s", device->priv->props->device_file);
return device;
error:
diff --git a/src/gdu/gdu-pool.c b/src/gdu/gdu-pool.c
index 8435822..0a337ed 100644
--- a/src/gdu/gdu-pool.c
+++ b/src/gdu/gdu-pool.c
@@ -249,8 +249,40 @@ gdu_pool_class_init (GduPoolClass *klass)
}
static void
+gdu_log_func (const gchar *log_domain,
+ GLogLevelFlags log_level,
+ const gchar *message,
+ gpointer user_data)
+{
+ gboolean show_debug;
+ const gchar *gdu_debug_var;
+
+ gdu_debug_var = g_getenv ("GDU_DEBUG");
+ show_debug = (g_strcmp0 (gdu_debug_var, "1") == 0);
+
+ if (G_LIKELY (!show_debug))
+ goto out;
+
+ g_print ("%s: %s\n",
+ G_LOG_DOMAIN,
+ message);
+ out:
+ ;
+}
+
+static void
gdu_pool_init (GduPool *pool)
{
+ static gboolean log_handler_initialized = FALSE;
+
+ if (!log_handler_initialized) {
+ g_log_set_handler (G_LOG_DOMAIN,
+ G_LOG_LEVEL_MESSAGE | G_LOG_LEVEL_INFO | G_LOG_LEVEL_DEBUG,
+ gdu_log_func,
+ NULL);
+ log_handler_initialized = TRUE;
+ }
+
pool->priv = G_TYPE_INSTANCE_GET_PRIVATE (pool, GDU_TYPE_POOL, GduPoolPrivate);
pool->priv->object_path_to_device = g_hash_table_new_full (g_str_hash,