summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon McVittie <simon.mcvittie@collabora.co.uk>2007-11-08 17:15:00 +0000
committerSimon McVittie <simon.mcvittie@collabora.co.uk>2007-11-08 17:15:00 +0000
commitcc28763013d1dcf116d1fffa2b699a758626af33 (patch)
tree30fa14cb12fe2b5ea0faea5d17e49451f9d19a92
parent4a735f03e62904de95f28c689585fefffa9466df (diff)
downloadtelepathy-glib-cc28763013d1dcf116d1fffa2b699a758626af33.tar.gz
Add tp_debug_set_flags(), which doesn't accept the "persist" flag. Deprecate the related functions that did include the "persist" flag, and make the implementations more orthogonal.
20071108171500-53eee-dff8a1842466d84b2014831887eb963f85ba54b4.gz
-rw-r--r--docs/reference/telepathy-glib-sections.txt4
-rw-r--r--telepathy-glib/debug.c77
-rw-r--r--telepathy-glib/debug.h11
-rw-r--r--telepathy-glib/internal-debug.h11
-rw-r--r--telepathy-glib/run.c8
-rw-r--r--tests/test-internal-debug.c2
6 files changed, 74 insertions, 39 deletions
diff --git a/docs/reference/telepathy-glib-sections.txt b/docs/reference/telepathy-glib-sections.txt
index 520159805..106413909 100644
--- a/docs/reference/telepathy-glib-sections.txt
+++ b/docs/reference/telepathy-glib-sections.txt
@@ -1098,10 +1098,12 @@ TP_PRESENCE_MIXIN
<FILE>debug</FILE>
<TITLE>debug</TITLE>
<INCLUDE>telepathy-glib/debug.h</INCLUDE>
+tp_debug_set_flags
+tp_debug_set_persistent
+<SUBSECTION>
tp_debug_set_flags_from_string
tp_debug_set_flags_from_env
tp_debug_set_all_flags
-tp_debug_set_persistent
</SECTION>
<SECTION>
diff --git a/telepathy-glib/debug.c b/telepathy-glib/debug.c
index bbde77f97..168044a8c 100644
--- a/telepathy-glib/debug.c
+++ b/telepathy-glib/debug.c
@@ -29,25 +29,10 @@
* is activated, it should call tp_debug_set_flags_from_string(),
* tp_debug_set_flags_from_env() or tp_debug_set_all_flags().
*
- * For example, at the time of writing Gabble has the following behaviour:
- *
- * <itemizedlist>
- * <listitem>The environment variable $GABBLE_DEBUG contains a comma-separated
- * list of debug modes to activate. In addition to parsing this variable
- * itself, Gabble calls
- * <literal>tp_debug_set_flags_from_env ("GABBLE_DEBUG")</literal>.</listitem>
- * <listitem>The environment variable $GABBLE_PERSIST activates all possible
- * debug modes. If this variable is set, in addition to activating all of
- * its own debug modes, Gabble calls tp_debug_set_all_flags() to activate
- * all possible debug output in telepathy-glib.</listitem>
- * </itemizedlist>
- *
* The supported debug-mode keywords are subject to change, but currently
* include:
*
* <itemizedlist>
- * <listitem><literal>persist</literal> - keep running even if there are no
- * connections for a while</listitem>
* <listitem><literal>connection</literal> - output debug messages regarding
* #TpBaseConnection</listitem>
* <listitem><literal>im</literal> - output debug messages regarding
@@ -78,27 +63,36 @@ static gboolean tp_debug_persistent = FALSE;
/**
* tp_debug_set_all_flags:
*
- * Activate all possible debug modes.
+ * Activate all possible debug modes. This also activates persistent mode,
+ * which should have been orthogonal.
+ *
+ * @deprecated since 0.6.1. Use tp_debug_set_flags ("all") and
+ * tp_debug_set_persistent() instead.
*/
void
tp_debug_set_all_flags (void)
{
flags = 0xffff;
+ tp_debug_persistent = TRUE;
}
static GDebugKey keys[] = {
{ "groups", TP_DEBUG_GROUPS },
{ "properties", TP_DEBUG_PROPERTIES },
{ "connection", TP_DEBUG_CONNECTION },
- { "persist", TP_DEBUG_PERSIST },
{ "im", TP_DEBUG_IM },
{ "params", TP_DEBUG_PARAMS },
{ "presence", TP_DEBUG_PRESENCE },
{ 0, },
};
+static GDebugKey persist_keys[] = {
+ { "persist", 1 },
+ { 0, },
+};
+
/**
- * tp_debug_set_flags_from_string:
+ * tp_debug_set_flags:
* @flags_string: The flags to set, comma-separated. If %NULL or empty,
* no additional flags are set.
*
@@ -106,30 +100,65 @@ static GDebugKey keys[] = {
* set.
*
* The parsing matches that of g_parse_debug_string().
+ *
+ * @since 0.6.1
*/
void
-tp_debug_set_flags_from_string (const gchar *flags_string)
+tp_debug_set_flags (const gchar *flags_string)
{
guint nkeys;
for (nkeys = 0; keys[nkeys].value; nkeys++);
- if (flags_string)
+ if (flags_string != NULL)
_tp_debug_set_flags (g_parse_debug_string (flags_string, keys, nkeys));
}
/**
+ * tp_debug_set_flags_from_string:
+ * @flags_string: The flags to set, comma-separated. If %NULL or empty,
+ * no additional flags are set.
+ *
+ * Set the debug flags indicated by @flags_string, in addition to any already
+ * set. Unlike tp_debug_set_flags(), this enables persistence like
+ * tp_debug_set_persistent() if the "persist" flag is present or the string
+ * is "all" - this turns out to be unhelpful, as persistence should be
+ * orthogonal.
+ *
+ * The parsing matches that of g_parse_debug_string().
+ *
+ * @deprecated since 0.6.1. Use tp_debug_set_flags() and
+ * tp_debug_set_persistent() instead
+ */
+void
+tp_debug_set_flags_from_string (const gchar *flags_string)
+{
+ tp_debug_set_flags (flags_string);
+
+ if (flags_string != NULL &&
+ g_parse_debug_string (flags_string, persist_keys, 1) != 0)
+ tp_debug_set_persistent (TRUE);
+}
+
+/**
* tp_debug_set_flags_from_env:
* @var: The name of the environment variable to parse
*
- * Set the debug flags indicated by the given environment variable, in
- * addition to any already set. Equivalent to
- * <literal>tp_debug_set_flags_from_string (g_getenv (var))</literal>.
+ * Equivalent to
+ * <literal>tp_debug_set_flags_from_string (g_getenv (var))</literal>,
+ * and has the same problem with persistence being included in "all".
+ *
+ * @deprecated since 0.6.1. Use tp_debug_set_flags(g_getenv(...)) and
+ * tp_debug_set_persistent() instead
*/
void
tp_debug_set_flags_from_env (const gchar *var)
{
- tp_debug_set_flags_from_string (g_getenv (var));
+ const gchar *val = g_getenv (var);
+
+ tp_debug_set_flags (val);
+ if (val != NULL && g_parse_debug_string (val, persist_keys, 1) != 0)
+ tp_debug_set_persistent (TRUE);
}
/**
diff --git a/telepathy-glib/debug.h b/telepathy-glib/debug.h
index aaac79a32..d251c4b25 100644
--- a/telepathy-glib/debug.h
+++ b/telepathy-glib/debug.h
@@ -5,11 +5,16 @@
G_BEGIN_DECLS
-void tp_debug_set_flags_from_string (const gchar *flags_string);
-void tp_debug_set_flags_from_env (const gchar *var);
-void tp_debug_set_all_flags (void);
+void tp_debug_set_flags (const gchar *flags_string);
+
void tp_debug_set_persistent (gboolean persistent);
+void tp_debug_set_flags_from_string (const gchar *flags_string)
+ G_GNUC_DEPRECATED;
+void tp_debug_set_flags_from_env (const gchar *var)
+ G_GNUC_DEPRECATED;
+void tp_debug_set_all_flags (void) G_GNUC_DEPRECATED;
+
G_END_DECLS
#endif
diff --git a/telepathy-glib/internal-debug.h b/telepathy-glib/internal-debug.h
index 0d4e28d3f..2bffe51e5 100644
--- a/telepathy-glib/internal-debug.h
+++ b/telepathy-glib/internal-debug.h
@@ -19,9 +19,8 @@ typedef enum
TP_DEBUG_PROPERTIES = 1 << 2,
TP_DEBUG_IM = 1 << 3,
TP_DEBUG_CONNECTION = 1 << 4,
- TP_DEBUG_PERSIST = 1 << 5,
- TP_DEBUG_PARAMS = 1 << 6,
- TP_DEBUG_PRESENCE = 1 << 7
+ TP_DEBUG_PARAMS = 1 << 5,
+ TP_DEBUG_PRESENCE = 1 << 6
} TpDebugFlags;
gboolean _tp_debug_flag_is_set (TpDebugFlags flag);
@@ -30,8 +29,14 @@ void _tp_debug (TpDebugFlags flag, const gchar *format, ...)
G_GNUC_PRINTF (2, 3);
gboolean _tp_debug_is_persistent (void);
+#define _TP_DEBUG_IS_PERSISTENT (_tp_debug_is_persistent ())
+
G_END_DECLS
+#else
+
+#define _TP_DEBUG_IS_PERSISTENT (0)
+
#endif /* ENABLE_DEBUG */
#endif /* __DEBUG_H__ */
diff --git a/telepathy-glib/run.c b/telepathy-glib/run.c
index d74f3d0fb..e5233900b 100644
--- a/telepathy-glib/run.c
+++ b/telepathy-glib/run.c
@@ -62,13 +62,7 @@ static guint timeout_id = 0;
static gboolean
kill_connection_manager (gpointer data)
{
-#ifdef ENABLE_DEBUG
- if (!_tp_debug_is_persistent ()
- && !_tp_debug_flag_is_set (TP_DEBUG_PERSIST)
- && !connections_exist)
-#else
- if (!connections_exist)
-#endif
+ if (!_TP_DEBUG_IS_PERSISTENT && !connections_exist)
{
g_debug ("no connections, and timed out");
g_object_unref (manager);
diff --git a/tests/test-internal-debug.c b/tests/test-internal-debug.c
index 62163a217..e99688a79 100644
--- a/tests/test-internal-debug.c
+++ b/tests/test-internal-debug.c
@@ -71,7 +71,7 @@ int
main (int argc, char **argv)
{
/* We enable debugging for IM, but not for the connection. */
- tp_debug_set_flags_from_string ("im");
+ tp_debug_set_flags ("im");
test_debugging ();
test_not_debugging ();
test_debugging_again ();