summaryrefslogtreecommitdiff
path: root/common
diff options
context:
space:
mode:
authorNick Schermer <nick@xfce.org>2011-01-04 19:45:25 +0100
committerNick Schermer <nick@xfce.org>2011-01-04 19:45:25 +0100
commitdf0deff57e9a27cb30522fe0bb5b4834e10b6ab2 (patch)
treec9baed5b396aaa34a8c6d0d0d3febded099667e6 /common
parent6a2b1033cffb2ff7bc9a13445b437afab5cd15a4 (diff)
downloadxfce4-panel-df0deff57e9a27cb30522fe0bb5b4834e10b6ab2.tar.gz
Prepare for filtered debugging.
Diffstat (limited to 'common')
-rw-r--r--common/panel-debug.c74
-rw-r--r--common/panel-debug.h31
2 files changed, 70 insertions, 35 deletions
diff --git a/common/panel-debug.c b/common/panel-debug.c
index 0a76d27f..3f8e2f4a 100644
--- a/common/panel-debug.c
+++ b/common/panel-debug.c
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2010 Nick Schermer <nick@xfce.org>
+ * Copyright (C) 2010-2011 Nick Schermer <nick@xfce.org>
*
* This library is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the Free
@@ -37,28 +37,31 @@ PanelDebugFlag panel_debug_flags = 0;
/* additional debug levels */
static const GDebugKey panel_debug_keys[] =
{
+ { "main", PANEL_DEBUG_MAIN },
+ { "positioning", PANEL_DEBUG_POSITIONING },
+ { "display-layout", PANEL_DEBUG_DISPLAY_LAYOUT },
+ { "struts", PANEL_DEBUG_STRUTS },
+ { "application", PANEL_DEBUG_APPLICATION },
+ { "external", PANEL_DEBUG_EXTERNAL },
+ { "external46", PANEL_DEBUG_EXTERNAL46 },
+ { "tasklist", PANEL_DEBUG_TASKLIST },
+ { "base-window", PANEL_DEBUG_BASE_WINDOW },
+ { "applicationmenu", PANEL_DEBUG_APPLICATIONMENU },
{ "gdb", PANEL_DEBUG_GDB },
{ "valgrind", PANEL_DEBUG_VALGRIND }
};
-void
-panel_debug (const gchar *domain,
- const gchar *message,
- ...)
+static PanelDebugFlag
+panel_debug_init (void)
{
- static volatile gsize level__volatile = 0;
- const gchar *value;
- gchar *string, *path;
- va_list args;
- const gchar *proxy_application;
-
- panel_return_if_fail (domain != NULL);
- panel_return_if_fail (message != NULL);
+ static volatile gsize inited__volatile = 0;
+ const gchar *value;
+ gchar *path;
+ const gchar *proxy_application;
- /* initialize the debugging domains */
- if (g_once_init_enter (&level__volatile))
+ if (g_once_init_enter (&inited__volatile))
{
value = g_getenv ("PANEL_DEBUG");
if (value != NULL && *value != '\0')
@@ -66,7 +69,7 @@ panel_debug (const gchar *domain,
panel_debug_flags = g_parse_debug_string (value, panel_debug_keys,
G_N_ELEMENTS (panel_debug_keys));
- /* always enable debug logging */
+ /* always enable (unfiltered) debugging messages */
PANEL_SET_FLAG (panel_debug_flags, PANEL_DEBUG_YES);
if (PANEL_HAS_FLAG (panel_debug_flags, PANEL_DEBUG_GDB))
@@ -75,6 +78,9 @@ panel_debug (const gchar *domain,
/* performs sanity checks on the released memory slices */
g_setenv ("G_SLICE", "debug-blocks", TRUE);
+
+ /* make sure we don't run gdb and valgrind at the same time */
+ PANEL_UNSET_FLAG (panel_debug_flags, PANEL_DEBUG_VALGRIND);
}
else if (PANEL_HAS_FLAG (panel_debug_flags, PANEL_DEBUG_VALGRIND))
{
@@ -109,17 +115,47 @@ panel_debug (const gchar *domain,
}
}
- g_once_init_leave (&level__volatile, 1);
+ g_once_init_leave (&inited__volatile, 1);
}
+ return panel_debug_flags;
+}
+
+
+
+void
+panel_debug (PanelDebugFlag domain,
+ const gchar *message,
+ ...)
+{
+ gchar *string;
+ va_list args;
+ const gchar *domain_name = NULL;
+ guint i;
+
+ panel_return_if_fail (domain > 0);
+ panel_return_if_fail (message != NULL);
+
/* leave when debug is disabled */
- if (panel_debug_flags == 0)
+ if (panel_debug_init () == 0)
return;
+ /* lookup domain name */
+ for (i = 0; i < G_N_ELEMENTS (panel_debug_keys); i++)
+ {
+ if (panel_debug_keys[i].value == domain)
+ {
+ domain_name = panel_debug_keys[i].key;
+ break;
+ }
+ }
+
+ panel_assert (domain_name != NULL);
+
va_start (args, message);
string = g_strdup_vprintf (message, args);
va_end (args);
- g_printerr (PACKAGE_NAME "(%s): %s\n", domain, string);
+ g_printerr (PACKAGE_NAME "(%s): %s\n", domain_name, string);
g_free (string);
}
diff --git a/common/panel-debug.h b/common/panel-debug.h
index 8cf3a85b..b05211e3 100644
--- a/common/panel-debug.h
+++ b/common/panel-debug.h
@@ -19,31 +19,30 @@
#ifndef __PANEL_DEBUG_H__
#define __PANEL_DEBUG_H__
-#define PANEL_DEBUG_DOMAIN_MAIN "main"
-#define PANEL_DEBUG_DOMAIN_POSITIONING "positioning"
-#define PANEL_DEBUG_DOMAIN_DISPLAY_LAYOUT "display-layout"
-#define PANEL_DEBUG_DOMAIN_STRUTS "struts"
-#define PANEL_DEBUG_DOMAIN_APPLICATION "application"
-#define PANEL_DEBUG_DOMAIN_EXTERNAL "external"
-#define PANEL_DEBUG_DOMAIN_EXTERNAL46 "external46"
-#define PANEL_DEBUG_DOMAIN_TASKLIST "tasklist"
-#define PANEL_DEBUG_DOMAIN_BASE_WINDOW "base-window"
-#define PANEL_DEBUG_DOMAIN_APPLICATIONMENU "applicationmenu"
-
#define PANEL_DEBUG_BOOL(bool) ((bool) ? "true" : "false")
typedef enum
{
- PANEL_DEBUG_YES = 1 << 0, /* always enabled if PANEL_DEBUG is not %NULL */
- PANEL_DEBUG_GDB = 1 << 1, /* run plugin in gdb */
- PANEL_DEBUG_VALGRIND = 1 << 2 /* run plugin in valgrind */
+ PANEL_DEBUG_YES = 1 << 0, /* always enabled if PANEL_DEBUG is not %NULL */
+ PANEL_DEBUG_MAIN = 1 << 1,
+ PANEL_DEBUG_POSITIONING = 1 << 2,
+ PANEL_DEBUG_DISPLAY_LAYOUT = 1 << 3,
+ PANEL_DEBUG_STRUTS = 1 << 4,
+ PANEL_DEBUG_APPLICATION = 1 << 5,
+ PANEL_DEBUG_EXTERNAL = 1 << 6,
+ PANEL_DEBUG_EXTERNAL46 = 1 << 7,
+ PANEL_DEBUG_TASKLIST = 1 << 8,
+ PANEL_DEBUG_BASE_WINDOW = 1 << 9,
+ PANEL_DEBUG_APPLICATIONMENU = 1 << 10,
+ PANEL_DEBUG_GDB = 1 << 11, /* run plugin in gdb */
+ PANEL_DEBUG_VALGRIND = 1 << 12 /* run plugin in valgrind */
}
PanelDebugFlag;
extern PanelDebugFlag panel_debug_flags;
-void panel_debug (const gchar *domain,
- const gchar *message,
+void panel_debug (PanelDebugFlag domain,
+ const gchar *message,
...) G_GNUC_PRINTF (2, 3);
#endif /* !__PANEL_DEBUG_H__ */