[totem] Bug 606036 — Fix debug logging



commit bc39c6554c53cb141396b8c4d7be3afaac46df3b
Author: Philip Withnall <philip tecnocode co uk>
Date:   Mon Jan 4 18:13:28 2010 +0000

    Bug 606036 â?? Fix debug logging
    
    Fix debug logging by defining a log domain for all of Totem and installing a
    log handler for that domain for debug messages. Messages are suppressed unless
    the --debug command line option is passed. Closes: bgo#606036

 src/Makefile.am                               |   35 +++++++++++++++----------
 src/plugins/Makefile.am                       |    1 +
 src/plugins/bemused/Makefile.am               |    1 +
 src/plugins/brasero-disc-recorder/Makefile.am |    1 +
 src/plugins/galago/Makefile.am                |    1 +
 src/plugins/gromit/Makefile.am                |    1 +
 src/plugins/lirc/Makefile.am                  |    1 +
 src/plugins/media-player-keys/Makefile.am     |    1 +
 src/plugins/mythtv/Makefile.am                |    1 +
 src/plugins/ontop/Makefile.am                 |    1 +
 src/plugins/properties/Makefile.am            |    1 +
 src/plugins/publish/Makefile.am               |    1 +
 src/plugins/screensaver/Makefile.am           |    1 +
 src/plugins/screenshot/Makefile.am            |    1 +
 src/plugins/sidebar-test/Makefile.am          |    1 +
 src/plugins/skipto/Makefile.am                |    1 +
 src/plugins/thumbnail/Makefile.am             |    1 +
 src/plugins/tracker/Makefile.am               |    1 +
 src/plugins/youtube/Makefile.am               |    1 +
 src/totem.c                                   |   21 +++++++++++++++
 20 files changed, 60 insertions(+), 14 deletions(-)
---
diff --git a/src/Makefile.am b/src/Makefile.am
index cb4a8a3..b9194a8 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -34,9 +34,10 @@ libtotem_player_la_SOURCES = \
 	totem-time-label.h
 
 libtotem_player_la_CPPFLAGS = \
-	-I$(srcdir)/backend	\
-	-I$(top_srcdir)/	\
-	$(common_defines)	\
+	-I$(srcdir)/backend		\
+	-I$(top_srcdir)/		\
+	$(common_defines)		\
+	-DG_LOG_DOMAIN=\""Totem"\"	\
 	$(AM_CPPFLAGS)
 
 libtotem_player_la_CFLAGS = \
@@ -92,6 +93,7 @@ libtotem_main_la_CPPFLAGS = \
 	-I$(srcdir)/plugins		\
 	-I$(top_builddir)/data		\
 	$(common_defines)		\
+	-DG_LOG_DOMAIN=\""Totem"\"	\
 	$(AM_CPPFLAGS)
 
 libtotem_main_la_CFLAGS = \
@@ -173,6 +175,7 @@ totem_CPPFLAGS =			\
 	-I$(top_srcdir)/		\
 	-I$(srcdir)/backend		\
 	$(common_defines)		\
+	-DG_LOG_DOMAIN=\""Totem"\"	\
 	$(AM_CPPFLAGS)
 
 totem_CFLAGS =				\
@@ -199,9 +202,10 @@ totem_video_thumbnailer_SOURCES =	\
 	totem-resources.h
 
 totem_video_thumbnailer_CPPFLAGS = \
-	-I$(top_srcdir)/	\
-	-I$(srcdir)/backend	\
-	$(common_defines)	\
+	-I$(top_srcdir)/				\
+	-I$(srcdir)/backend				\
+	$(common_defines)				\
+	-DG_LOG_DOMAIN=\""TotemVideoThumbnailer"\"	\
 	$(AM_CPPFLAGS)
 
 totem_video_thumbnailer_CFLAGS = \
@@ -238,6 +242,7 @@ libtotem_properties_page_la_CPPFLAGS =		\
 	-I$(srcdir)/plugins/properties		\
 	-I$(top_builddir)/data			\
 	$(common_defines)			\
+	-DG_LOG_DOMAIN=\""TotemPropertiesPage"\"\
 	$(AM_CPPFLAGS)
 
 libtotem_properties_page_la_CFLAGS = \
@@ -305,10 +310,11 @@ totem_video_indexer_SOURCES =		\
 	totem-resources.h
 
 totem_video_indexer_CPPFLAGS = \
-	-I$(top_srcdir)/	\
-	-I$(srcdir)/backend	\
-	-I$(top_builddir)/data	\
-	$(common_defines)	\
+	-I$(top_srcdir)/			\
+	-I$(srcdir)/backend			\
+	-I$(top_builddir)/data			\
+	$(common_defines)			\
+	-DG_LOG_DOMAIN=\""TotemVideoIndexer"\"	\
 	$(AM_CPPFLAGS)
 
 totem_video_indexer_CFLAGS = \
@@ -334,10 +340,11 @@ totem_audio_preview_SOURCES =		\
 	totem-resources.h
 
 totem_audio_preview_CPPFLAGS =	\
-	-I$(top_srcdir)/	\
-	-I$(srcdir)/backend	\
-	-I$(top_builddir)/data	\
-	$(common_defines)	\
+	-I$(top_srcdir)/			\
+	-I$(srcdir)/backend			\
+	-I$(top_builddir)/data			\
+	$(common_defines)			\
+	-DG_LOG_DOMAIN=\""TotemAudioPreview"\"	\
 	$(AM_CPPFLAGS)
 
 totem_audio_preview_CFLAGS = \
diff --git a/src/plugins/Makefile.am b/src/plugins/Makefile.am
index 8939806..92e4dc6 100644
--- a/src/plugins/Makefile.am
+++ b/src/plugins/Makefile.am
@@ -12,6 +12,7 @@ common_defines = \
 	-DLIBEXECDIR=\""$(libexecdir)"\"		\
 	-DBINDIR=\""$(bindir)"\"			\
 	-DTOTEM_PLUGIN_DIR=\""$(libdir)/totem/plugins"\"\
+	-DG_LOG_DOMAIN=\""Totem"\"			\
 	$(DISABLE_DEPRECATED)
 
 modules_flags = -export_dynamic -avoid-version -module
diff --git a/src/plugins/bemused/Makefile.am b/src/plugins/bemused/Makefile.am
index 2a6eed5..5faa884 100644
--- a/src/plugins/bemused/Makefile.am
+++ b/src/plugins/bemused/Makefile.am
@@ -18,6 +18,7 @@ common_defines = \
 	-DLIBEXECDIR=\""$(libexecdir)"\"		\
 	-DBINDIR=\""$(bindir)"\"			\
 	-DTOTEM_PLUGIN_DIR=\""$(libdir)/totem/plugins"\"\
+	-DG_LOG_DOMAIN=\""Totem"\"			\
 	$(DISABLE_DEPRECATED)
 
 libbemused_la_SOURCES = totem-bemused.c
diff --git a/src/plugins/brasero-disc-recorder/Makefile.am b/src/plugins/brasero-disc-recorder/Makefile.am
index 38add46..7dc84b3 100644
--- a/src/plugins/brasero-disc-recorder/Makefile.am
+++ b/src/plugins/brasero-disc-recorder/Makefile.am
@@ -18,6 +18,7 @@ common_defines = \
 	-DLIBEXECDIR=\""$(libexecdir)"\"		\
 	-DBINDIR=\""$(bindir)"\"			\
 	-DTOTEM_PLUGIN_DIR=\""$(libdir)/totem/plugins"\"\
+	-DG_LOG_DOMAIN=\""Totem"\"			\
 	$(DISABLE_DEPRECATED)
 
 libbrasero_disc_recorder_la_SOURCES = totem-disc-recorder.c
diff --git a/src/plugins/galago/Makefile.am b/src/plugins/galago/Makefile.am
index 3ccbc93..14d0a02 100644
--- a/src/plugins/galago/Makefile.am
+++ b/src/plugins/galago/Makefile.am
@@ -18,6 +18,7 @@ common_defines = \
 	-DLIBEXECDIR=\""$(libexecdir)"\"		\
 	-DBINDIR=\""$(bindir)"\"			\
 	-DTOTEM_PLUGIN_DIR=\""$(libdir)/totem/plugins"\"\
+	-DG_LOG_DOMAIN=\""Totem"\"			\
 	$(DISABLE_DEPRECATED)
 
 libtgp_la_SOURCES = totem-galago.c
diff --git a/src/plugins/gromit/Makefile.am b/src/plugins/gromit/Makefile.am
index ba3e5db..452c56f 100644
--- a/src/plugins/gromit/Makefile.am
+++ b/src/plugins/gromit/Makefile.am
@@ -18,6 +18,7 @@ common_defines = \
 	-DLIBEXECDIR=\""$(libexecdir)"\"		\
 	-DBINDIR=\""$(bindir)"\"			\
 	-DTOTEM_PLUGIN_DIR=\""$(libdir)/totem/plugins"\"\
+	-DG_LOG_DOMAIN=\""Totem"\"			\
 	$(DISABLE_DEPRECATED)
 
 libgromit_la_SOURCES = totem-gromit.c
diff --git a/src/plugins/lirc/Makefile.am b/src/plugins/lirc/Makefile.am
index b292229..f3de0bc 100644
--- a/src/plugins/lirc/Makefile.am
+++ b/src/plugins/lirc/Makefile.am
@@ -21,6 +21,7 @@ common_defines = \
 	-DLIBEXECDIR=\""$(libexecdir)"\"		\
 	-DBINDIR=\""$(bindir)"\"			\
 	-DTOTEM_PLUGIN_DIR=\""$(libdir)/totem/plugins"\"\
+	-DG_LOG_DOMAIN=\""Totem"\"			\
 	$(DISABLE_DEPRECATED)
 
 liblirc_la_SOURCES = totem-lirc.c
diff --git a/src/plugins/media-player-keys/Makefile.am b/src/plugins/media-player-keys/Makefile.am
index 48f158b..da8368d 100644
--- a/src/plugins/media-player-keys/Makefile.am
+++ b/src/plugins/media-player-keys/Makefile.am
@@ -18,6 +18,7 @@ common_defines = \
 	-DLIBEXECDIR=\""$(libexecdir)"\"		\
 	-DBINDIR=\""$(bindir)"\"			\
 	-DTOTEM_PLUGIN_DIR=\""$(libdir)/totem/plugins"\"\
+	-DG_LOG_DOMAIN=\""Totem"\"			\
 	$(DISABLE_DEPRECATED)
 
 libmedia_player_keys_la_SOURCES = totem-media-player-keys.c $(BUILT_SOURCES)
diff --git a/src/plugins/mythtv/Makefile.am b/src/plugins/mythtv/Makefile.am
index 791f348..eecf45e 100644
--- a/src/plugins/mythtv/Makefile.am
+++ b/src/plugins/mythtv/Makefile.am
@@ -27,6 +27,7 @@ common_defines = \
 	-DLIBEXECDIR=\""$(libexecdir)"\"		\
 	-DBINDIR=\""$(bindir)"\"			\
 	-DTOTEM_PLUGIN_DIR=\""$(libdir)/totem/plugins"\"\
+	-DG_LOG_DOMAIN=\""Totem"\"			\
 	$(DISABLE_DEPRECATED)
 
 libtotem_mythtv_la_SOURCES = totem-mythtv.c
diff --git a/src/plugins/ontop/Makefile.am b/src/plugins/ontop/Makefile.am
index 2704230..bf52c09 100644
--- a/src/plugins/ontop/Makefile.am
+++ b/src/plugins/ontop/Makefile.am
@@ -18,6 +18,7 @@ common_defines = \
 	-DLIBEXECDIR=\""$(libexecdir)"\"		\
 	-DBINDIR=\""$(bindir)"\"			\
 	-DTOTEM_PLUGIN_DIR=\""$(libdir)/totem/plugins"\"\
+	-DG_LOG_DOMAIN=\""Totem"\"			\
 	$(DISABLE_DEPRECATED)
 
 libontop_la_SOURCES = totem-ontop.c
diff --git a/src/plugins/properties/Makefile.am b/src/plugins/properties/Makefile.am
index 8374280..228234c 100644
--- a/src/plugins/properties/Makefile.am
+++ b/src/plugins/properties/Makefile.am
@@ -20,6 +20,7 @@ common_defines = \
 	-DLIBEXECDIR=\""$(libexecdir)"\"		\
 	-DBINDIR=\""$(bindir)"\"			\
 	-DTOTEM_PLUGIN_DIR=\""$(libdir)/totem/plugins"\"\
+	-DG_LOG_DOMAIN=\""Totem"\"			\
 	$(DISABLE_DEPRECATED)
 
 libmovie_properties_la_SOURCES = totem-movie-properties.c
diff --git a/src/plugins/publish/Makefile.am b/src/plugins/publish/Makefile.am
index e766240..83ebfcd 100644
--- a/src/plugins/publish/Makefile.am
+++ b/src/plugins/publish/Makefile.am
@@ -21,6 +21,7 @@ common_defines = \
 	-DLIBEXECDIR=\""$(libexecdir)"\"		\
 	-DBINDIR=\""$(bindir)"\"			\
 	-DTOTEM_PLUGIN_DIR=\""$(libdir)/totem/plugins"\"\
+	-DG_LOG_DOMAIN=\""Totem"\"			\
 	$(DISABLE_DEPRECATED)
 
 libpublish_la_SOURCES = totem-publish.c
diff --git a/src/plugins/screensaver/Makefile.am b/src/plugins/screensaver/Makefile.am
index a406eae..5f2c9ce 100644
--- a/src/plugins/screensaver/Makefile.am
+++ b/src/plugins/screensaver/Makefile.am
@@ -18,6 +18,7 @@ common_defines = \
 	-DLIBEXECDIR=\""$(libexecdir)"\"		\
 	-DBINDIR=\""$(bindir)"\"			\
 	-DTOTEM_PLUGIN_DIR=\""$(libdir)/totem/plugins"\"\
+	-DG_LOG_DOMAIN=\""Totem"\"			\
 	$(DISABLE_DEPRECATED)
 
 libscreensaver_la_SOURCES = totem-screensaver.c
diff --git a/src/plugins/screenshot/Makefile.am b/src/plugins/screenshot/Makefile.am
index e6305fb..20b0017 100644
--- a/src/plugins/screenshot/Makefile.am
+++ b/src/plugins/screenshot/Makefile.am
@@ -20,6 +20,7 @@ common_defines = \
 	-DLIBEXECDIR=\""$(libexecdir)"\"		\
 	-DBINDIR=\""$(bindir)"\"			\
 	-DTOTEM_PLUGIN_DIR=\""$(libdir)/totem/plugins"\"\
+	-DG_LOG_DOMAIN=\""Totem"\"			\
 	$(DISABLE_DEPRECATED)
 
 libscreenshot_la_SOURCES = \
diff --git a/src/plugins/sidebar-test/Makefile.am b/src/plugins/sidebar-test/Makefile.am
index e8b13a6..ff75e89 100644
--- a/src/plugins/sidebar-test/Makefile.am
+++ b/src/plugins/sidebar-test/Makefile.am
@@ -20,6 +20,7 @@ common_defines = \
 	-DLIBEXECDIR=\""$(libexecdir)"\"		\
 	-DBINDIR=\""$(bindir)"\"			\
 	-DTOTEM_PLUGIN_DIR=\""$(libdir)/totem/plugins"\"\
+	-DG_LOG_DOMAIN=\""Totem"\"			\
 	$(DISABLE_DEPRECATED)
 
 libsidebar_test_la_SOURCES = totem-sidebar-test.c
diff --git a/src/plugins/skipto/Makefile.am b/src/plugins/skipto/Makefile.am
index bce8f62..e566770 100644
--- a/src/plugins/skipto/Makefile.am
+++ b/src/plugins/skipto/Makefile.am
@@ -20,6 +20,7 @@ common_defines = \
 	-DLIBEXECDIR=\""$(libexecdir)"\"		\
 	-DBINDIR=\""$(bindir)"\"			\
 	-DTOTEM_PLUGIN_DIR=\""$(libdir)/totem/plugins"\"\
+	-DG_LOG_DOMAIN=\""Totem"\"			\
 	$(DISABLE_DEPRECATED)
 
 libskipto_la_SOURCES = \
diff --git a/src/plugins/thumbnail/Makefile.am b/src/plugins/thumbnail/Makefile.am
index 08404ce..371a375 100644
--- a/src/plugins/thumbnail/Makefile.am
+++ b/src/plugins/thumbnail/Makefile.am
@@ -18,6 +18,7 @@ common_defines = \
 	-DLIBEXECDIR=\""$(libexecdir)"\"		\
 	-DBINDIR=\""$(bindir)"\"			\
 	-DTOTEM_PLUGIN_DIR=\""$(libdir)/totem/plugins"\"\
+	-DG_LOG_DOMAIN=\""Totem"\"			\
 	$(DISABLE_DEPRECATED)
 
 libthumbnail_la_SOURCES = totem-thumbnail.c
diff --git a/src/plugins/tracker/Makefile.am b/src/plugins/tracker/Makefile.am
index ec3e7b3..3a0af32 100644
--- a/src/plugins/tracker/Makefile.am
+++ b/src/plugins/tracker/Makefile.am
@@ -18,6 +18,7 @@ common_defines = \
 	-DLIBEXECDIR=\""$(libexecdir)"\"		\
 	-DBINDIR=\""$(bindir)"\"			\
 	-DTOTEM_PLUGIN_DIR=\""$(libdir)/totem/plugins"\"\
+	-DG_LOG_DOMAIN=\""Totem"\"			\
 	$(DISABLE_DEPRECATED)
 
 libtracker_la_SOURCES = totem-tracker.c totem-tracker-widget.h totem-tracker-widget.c
diff --git a/src/plugins/youtube/Makefile.am b/src/plugins/youtube/Makefile.am
index 5550b1f..c12af21 100644
--- a/src/plugins/youtube/Makefile.am
+++ b/src/plugins/youtube/Makefile.am
@@ -21,6 +21,7 @@ common_defines = \
 	-DLIBEXECDIR=\""$(libexecdir)"\"		\
 	-DBINDIR=\""$(bindir)"\"			\
 	-DTOTEM_PLUGIN_DIR=\""$(libdir)/totem/plugins"\"\
+	-DG_LOG_DOMAIN=\""Totem"\"			\
 	$(DISABLE_DEPRECATED)
 
 libyoutube_la_SOURCES = totem-youtube.c
diff --git a/src/totem.c b/src/totem.c
index 61b2c18..5061bab 100644
--- a/src/totem.c
+++ b/src/totem.c
@@ -113,6 +113,23 @@ about_email_hook (GtkAboutDialog *about,
 	g_free (uri);
 }
 
+/* Debug log message handler: discards debug messages unless Totem is run with TOTEM_DEBUG=1.
+ * If we're building in the source tree, enable debug messages by default. */
+static void
+debug_handler (const char *log_domain,
+               GLogLevelFlags log_level,
+               const char *message,
+               GConfClient *gc)
+{
+	static int debug = -1;
+
+	if (debug < 0)
+		debug = gconf_client_get_bool (gc, GCONF_PREFIX"/debug", NULL);
+
+	if (debug)
+		g_log_default_handler (log_domain, log_level, message, NULL);
+}
+
 int
 main (int argc, char **argv)
 {
@@ -169,6 +186,10 @@ main (int argc, char **argv)
 		totem_action_error_and_exit (_("Totem could not initialize the configuration engine."), _("Make sure that GNOME is properly installed."), NULL);
 	}
 
+	/* Debug log handling */
+	g_log_set_handler (G_LOG_DOMAIN, G_LOG_LEVEL_DEBUG, (GLogFunc) debug_handler, gc);
+
+	/* Build the main Totem object */
 	totem = g_object_new (TOTEM_TYPE_OBJECT, NULL);
 	totem->gc = gc;
 



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