From f3d1653f13f05bbcdda932310daf31f57d61aa5e Mon Sep 17 00:00:00 2001 From: Giovanni Campagna Date: Mon, 20 May 2013 00:12:09 +0200 Subject: [PATCH] Improve handling of warnings and criticals Instead of squash everything into "window manager warnings", let the glib log framework handle Mutter (and other) warnings. META_USE_LOGFILE support is preserved by rerouting warnings in our domain. This way we get process name and PID, nice CRITICAL/WARNING/ERROR instead of a number, and the ability for plugins to override the log handler. For example gnome-shell uses this to output a JS backtrace. --- src/Makefile.am | 2 +- src/core/main.c | 36 +-------------- src/core/util.c | 113 +++++++++++++++++++++++------------------------- src/meta/util.h | 2 + 4 files changed, 58 insertions(+), 95 deletions(-) diff --git a/src/Makefile.am b/src/Makefile.am index 5a20ef1f4..5f2b10dd6 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -19,7 +19,7 @@ INCLUDES= \ -DMUTTER_LOCALEDIR=\"$(prefix)/@DATADIRNAME@/locale\" \ -DMUTTER_PKGDATADIR=\"$(pkgdatadir)\" \ -DMUTTER_DATADIR=\"$(datadir)\" \ - -DG_LOG_DOMAIN=\"mutter\" \ + -DG_LOG_DOMAIN=\"Mutter\" \ -DSN_API_NOT_YET_FROZEN=1 \ -DMUTTER_MAJOR_VERSION=$(MUTTER_MAJOR_VERSION) \ -DMUTTER_MINOR_VERSION=$(MUTTER_MINOR_VERSION) \ diff --git a/src/core/main.c b/src/core/main.c index 767a8b843..567e98892 100644 --- a/src/core/main.c +++ b/src/core/main.c @@ -93,26 +93,6 @@ static GMainLoop *meta_main_loop = NULL; static void prefs_changed_callback (MetaPreference pref, gpointer data); -/** - * log_handler: - * @log_domain: the domain the error occurred in (we ignore this) - * @log_level: the log level so that we can filter out less - * important messages - * @message: the message to log - * @user_data: arbitrary data (we ignore this) - * - * Prints log messages. If Mutter was compiled with backtrace support, - * also prints a backtrace (see meta_print_backtrace()). - */ -static void -log_handler (const gchar *log_domain, - GLogLevelFlags log_level, - const gchar *message, - gpointer user_data) -{ - meta_warning ("Log level %d: %s\n", log_level, message); -} - /** * meta_print_compilation_info: * @@ -411,6 +391,8 @@ meta_init (void) g_printerr ("Failed to register SIGTERM handler: %s\n", g_strerror (errno)); + meta_debug_init (); + if (g_getenv ("MUTTER_VERBOSE")) meta_set_verbose (TRUE); if (g_getenv ("MUTTER_DEBUG")) @@ -496,24 +478,10 @@ meta_register_with_session (void) int meta_run (void) { - const gchar *log_domains[] = { - NULL, G_LOG_DOMAIN, "Gtk", "Gdk", "GLib", - "Pango", "GLib-GObject", "GThread" - }; - guint i; - /* Load prefs */ meta_prefs_init (); meta_prefs_add_listener (prefs_changed_callback, NULL); - for (i=0; i