[metacity] util: allow logging only specific debug topics
- From: Alberts Muktupāvels <muktupavels src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [metacity] util: allow logging only specific debug topics
- Date: Fri, 10 Mar 2017 20:22:16 +0000 (UTC)
commit aa12bdb8b90e837d96882748531a18aa03fdf0e9
Author: Alberts Muktupāvels <alberts muktupavels gmail com>
Date: Fri Mar 10 15:23:13 2017 +0200
util: allow logging only specific debug topics
Replace existing METACITY_VERBOSE environment variable with
META_DEBUG. This allows to log only specific topic or topics.
This patch adds META_DEBUG_VERBOSE topic to log all meta_verbose
messages, but in long term meta_verbose should be replaced with
meta_topic.
Use META_DEBUG=all to get same behaviour.
src/core/constraints.c | 2 +-
src/core/display.c | 4 +-
src/core/edge-resistance.c | 2 +-
src/core/main.c | 10 +++----
src/core/screen.c | 2 +-
src/core/session.c | 2 +-
src/core/util.c | 62 ++++++++++++++++++++++++++++++++++++-------
src/core/window.c | 5 ++-
src/include/util.h | 10 +++++--
9 files changed, 72 insertions(+), 27 deletions(-)
---
diff --git a/src/core/constraints.c b/src/core/constraints.c
index 729d350..4828911 100644
--- a/src/core/constraints.c
+++ b/src/core/constraints.c
@@ -1300,7 +1300,7 @@ do_screen_and_xinerama_relative_constraints (
gboolean exit_early = FALSE, constraint_satisfied;
MetaRectangle how_far_it_can_be_smushed, min_size, max_size;
- if (meta_is_verbose ())
+ if (meta_check_debug_flags (META_DEBUG_GEOMETRY))
{
/* First, log some debugging information */
char spanning_region[1 + 28 * g_list_length (region_spanning_rectangles)];
diff --git a/src/core/display.c b/src/core/display.c
index 0fe78b8..313bfa9 100644
--- a/src/core/display.c
+++ b/src/core/display.c
@@ -2587,7 +2587,7 @@ event_callback (XEvent *event,
display->atom__METACITY_TOGGLE_VERBOSE)
{
meta_verbose ("Received toggle verbose message\n");
- meta_set_verbose (!meta_is_verbose ());
+ meta_toggle_debug ();
}
else if (event->xclient.message_type ==
display->atom_WM_PROTOCOLS)
@@ -2955,7 +2955,7 @@ meta_spew_event (MetaDisplay *display,
char *extra = NULL;
char *winname;
- if (!meta_is_verbose())
+ if (!meta_check_debug_flags (META_DEBUG_EVENTS))
return;
/* filter overnumerous events */
diff --git a/src/core/edge-resistance.c b/src/core/edge-resistance.c
index 9b171b9..d4b5301 100644
--- a/src/core/edge-resistance.c
+++ b/src/core/edge-resistance.c
@@ -774,7 +774,7 @@ cache_edges (MetaDisplay *display,
/*
* 0th: Print debugging information to the log about the edges
*/
- if (meta_is_verbose())
+ if (meta_check_debug_flags (META_DEBUG_EDGE_RESISTANCE))
{
int max_edges = MAX (MAX( g_list_length (window_edges),
g_list_length (xinerama_edges)),
diff --git a/src/core/main.c b/src/core/main.c
index 6998b53..2eb716f 100644
--- a/src/core/main.c
+++ b/src/core/main.c
@@ -112,8 +112,7 @@ version (void)
/**
* Prints a list of which configure script options were used to
* build this copy of Metacity. This is actually always called
- * on startup, but it's all no-op unless we're in verbose mode
- * (see meta_set_verbose).
+ * on startup, but it's all no-op unless we're in verbose mode.
*/
static void
meta_print_compilation_info (void)
@@ -150,8 +149,7 @@ meta_print_compilation_info (void)
* build date), the locale, the character encoding, and a list
* of configure script options that were used to build this
* copy of Metacity. This is actually always called
- * on startup, but it's all no-op unless we're in verbose mode
- * (see meta_set_verbose).
+ * on startup, but it's all no-op unless we're in verbose mode.
*/
static void
meta_print_self_identity (void)
@@ -394,8 +392,8 @@ main (int argc, char **argv)
g_printerr ("Failed to register SIGTERM handler: %s\n",
g_strerror (errno));
- if (g_getenv ("METACITY_VERBOSE"))
- meta_set_verbose (TRUE);
+ meta_init_debug ();
+
if (g_getenv ("METACITY_DEBUG"))
meta_set_debugging (TRUE);
diff --git a/src/core/screen.c b/src/core/screen.c
index 350a5af..7766fb6 100644
--- a/src/core/screen.c
+++ b/src/core/screen.c
@@ -2241,7 +2241,7 @@ meta_screen_calc_workspace_layout (MetaScreen *screen,
layout->current_row = current_row;
layout->current_col = current_col;
- if (meta_is_verbose ())
+ if (meta_check_debug_flags (META_DEBUG_VERBOSE))
{
r = 0;
while (r < layout->rows)
diff --git a/src/core/session.c b/src/core/session.c
index 95d44a4..3252f0e 100644
--- a/src/core/session.c
+++ b/src/core/session.c
@@ -1570,7 +1570,7 @@ get_possible_matches (MetaWindow *window)
}
else
{
- if (meta_is_verbose ())
+ if (meta_check_debug_flags (META_DEBUG_SM))
{
if (!both_null_or_matching (info->id, window->sm_client_id))
meta_topic (META_DEBUG_SM, "Window %s has SM client ID %s, saved state has %s, no match\n",
diff --git a/src/core/util.c b/src/core/util.c
index 58760b6..790cda0 100644
--- a/src/core/util.c
+++ b/src/core/util.c
@@ -35,7 +35,30 @@
#include <X11/Xlib.h> /* must explicitly be included for Solaris; #326746 */
#include <X11/Xutil.h> /* Just for the definition of the various gravities */
-static gboolean is_verbose = FALSE;
+static const GDebugKey debug_keys[] = {
+ { "focus", META_DEBUG_FOCUS },
+ { "workarea", META_DEBUG_WORKAREA },
+ { "stack", META_DEBUG_STACK },
+ { "sm", META_DEBUG_SM },
+ { "events", META_DEBUG_EVENTS },
+ { "window-state", META_DEBUG_WINDOW_STATE },
+ { "window-ops", META_DEBUG_WINDOW_OPS },
+ { "geometry", META_DEBUG_GEOMETRY },
+ { "placement", META_DEBUG_PLACEMENT },
+ { "ping", META_DEBUG_PING },
+ { "xinerama", META_DEBUG_XINERAMA },
+ { "keybindings", META_DEBUG_KEYBINDINGS },
+ { "sync", META_DEBUG_SYNC },
+ { "startup", META_DEBUG_STARTUP },
+ { "prefs", META_DEBUG_PREFS },
+ { "groups", META_DEBUG_GROUPS },
+ { "resizing", META_DEBUG_RESIZING },
+ { "shapes", META_DEBUG_SHAPES },
+ { "edge-resistance", META_DEBUG_EDGE_RESISTANCE },
+ { "verbose", META_DEBUG_VERBOSE }
+};
+
+static guint debug_flags = 0;
static gboolean is_debugging = FALSE;
static gboolean replace_current = FALSE;
static int no_prefix = 0;
@@ -85,19 +108,36 @@ ensure_logfile (void)
}
}
-gboolean
-meta_is_verbose (void)
+void
+meta_init_debug (void)
{
- return is_verbose;
+ debug_flags = g_parse_debug_string (g_getenv ("META_DEBUG"), debug_keys,
+ G_N_ELEMENTS (debug_keys));
+
+ if (debug_flags != 0)
+ ensure_logfile ();
}
void
-meta_set_verbose (gboolean setting)
+meta_toggle_debug (void)
{
- if (setting)
- ensure_logfile ();
+ if (debug_flags == 0)
+ {
+ debug_flags = g_parse_debug_string ("all", debug_keys,
+ G_N_ELEMENTS (debug_keys));
- is_verbose = setting;
+ ensure_logfile ();
+ }
+ else
+ {
+ debug_flags = 0;
+ }
+}
+
+gboolean
+meta_check_debug_flags (MetaDebugFlags flags)
+{
+ return (debug_flags & flags) != 0;
}
gboolean
@@ -178,7 +218,7 @@ meta_verbose (const char *format, ...)
g_return_if_fail (format != NULL);
- if (!is_verbose)
+ if ((debug_flags & META_DEBUG_VERBOSE) == 0)
return;
va_start (args, format);
@@ -239,6 +279,8 @@ topic_name (MetaDebugFlags topic)
return "SHAPES";
case META_DEBUG_EDGE_RESISTANCE:
return "EDGE_RESISTANCE";
+ case META_DEBUG_VERBOSE:
+ return "VERBOSE";
default:
break;
}
@@ -259,7 +301,7 @@ meta_topic (MetaDebugFlags topic,
g_return_if_fail (format != NULL);
- if (!is_verbose)
+ if ((debug_flags & topic) == 0)
return;
va_start (args, format);
diff --git a/src/core/window.c b/src/core/window.c
index a80a3da..ff0a11d 100644
--- a/src/core/window.c
+++ b/src/core/window.c
@@ -5457,7 +5457,7 @@ meta_window_client_message (MetaWindow *window,
first = event->xclient.data.l[1];
second = event->xclient.data.l[2];
- if (meta_is_verbose ())
+ if (meta_check_debug_flags (META_DEBUG_VERBOSE))
{
char *str1;
char *str2;
@@ -6010,7 +6010,8 @@ process_property_notify (MetaWindow *window,
{
Window xid = window->xwindow;
- if (meta_is_verbose ()) /* avoid looking up the name if we don't have to */
+ /* avoid looking up the name if we don't have to */
+ if (meta_check_debug_flags (META_DEBUG_VERBOSE))
{
char *property_name = XGetAtomName (window->display->xdisplay,
event->atom);
diff --git a/src/include/util.h b/src/include/util.h
index cbc5168..0090177 100644
--- a/src/include/util.h
+++ b/src/include/util.h
@@ -47,11 +47,15 @@ typedef enum
META_DEBUG_GROUPS = 1 << 15,
META_DEBUG_RESIZING = 1 << 16,
META_DEBUG_SHAPES = 1 << 17,
- META_DEBUG_EDGE_RESISTANCE = 1 << 18
+ META_DEBUG_EDGE_RESISTANCE = 1 << 18,
+ META_DEBUG_VERBOSE = 1 << 19
} MetaDebugFlags;
-gboolean meta_is_verbose (void);
-void meta_set_verbose (gboolean setting);
+void meta_init_debug (void);
+void meta_toggle_debug (void);
+
+gboolean meta_check_debug_flags (MetaDebugFlags flags);
+
gboolean meta_is_debugging (void);
void meta_set_debugging (gboolean setting);
gboolean meta_is_syncing (void);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]