[next] telepathy-glib: tpl_debug_set_flags: add

Simon McVittie smcv at kemper.freedesktop.org
Wed Mar 19 13:00:51 PDT 2014


Module: telepathy-glib
Branch: next
Commit: cb955db4e0affefd427280b5d18bb3b2914eeff3
URL:    http://cgit.freedesktop.org/telepathy/telepathy-glib/commit/?id=cb955db4e0affefd427280b5d18bb3b2914eeff3

Author: Simon McVittie <simon.mcvittie at collabora.co.uk>
Date:   Tue Mar 18 17:23:48 2014 +0000

tpl_debug_set_flags: add

Public API to set debug flags, from EMPATHY_DEBUG or similar,
seems a good thing to have.

Reviewed-by: Xavier Claessens

---

 telepathy-logger/Makefile.am        |    1 +
 telepathy-logger/debug-internal.h   |    6 +++---
 telepathy-logger/debug.c            |   12 +++++++-----
 telepathy-logger/debug.h            |   32 ++++++++++++++++++++++++++++++++
 telepathy-logger/telepathy-logger.h |    1 +
 5 files changed, 44 insertions(+), 8 deletions(-)

diff --git a/telepathy-logger/Makefile.am b/telepathy-logger/Makefile.am
index 4562074..ad4f881 100644
--- a/telepathy-logger/Makefile.am
+++ b/telepathy-logger/Makefile.am
@@ -49,6 +49,7 @@ EXTRA_DIST = \
 
 LIBTPLdir = $(includedir)/telepathy-logger-1/telepathy-logger
 LIBTPL_HEADERS = \
+		debug.h				\
 		entity.h			\
 		event.h				\
 		log-manager.h			\
diff --git a/telepathy-logger/debug-internal.h b/telepathy-logger/debug-internal.h
index 66e6178..e99522b 100644
--- a/telepathy-logger/debug-internal.h
+++ b/telepathy-logger/debug-internal.h
@@ -18,8 +18,8 @@
  * Authors: Cosimo Alfarano <cosimo.alfarano at collabora.co.uk>
  */
 
-#ifndef __TPL_DEBUG_H__
-#define __TPL_DEBUG_H__
+#ifndef __TPL_DEBUG_INTERNAL_H__
+#define __TPL_DEBUG_INTERNAL_H__
 
 #include "config.h"
 
@@ -95,4 +95,4 @@ G_STMT_START { \
 
 #endif /* DEBUG_FLAG */
 
-#endif /* __TPL_DEBUG_H__ */
+#endif /* __TPL_DEBUG_INTERNAL_H__ */
diff --git a/telepathy-logger/debug.c b/telepathy-logger/debug.c
index cd59a12..de9f44f 100644
--- a/telepathy-logger/debug.c
+++ b/telepathy-logger/debug.c
@@ -19,6 +19,7 @@
  */
 
 #include "config.h"
+#include "telepathy-logger/debug.h"
 #include "telepathy-logger/debug-internal.h"
 
 #include <telepathy-glib/telepathy-glib.h>
@@ -41,22 +42,23 @@ static GDebugKey keys[] = {
 };
 
 void
-_tpl_debug_set_flags_from_env (void)
+tpl_debug_set_flags (const gchar *flags_string)
 {
   guint nkeys;
-  const gchar *flags_string;
 
   for (nkeys = 0; keys[nkeys].value; nkeys++);
 
-  flags_string = g_getenv ("TPL_DEBUG");
-
   if (flags_string != NULL)
     _tpl_debug_set_flags (g_parse_debug_string (flags_string, keys, nkeys));
+}
 
+void
+_tpl_debug_set_flags_from_env (void)
+{
+  tpl_debug_set_flags (g_getenv ("TPL_DEBUG"));
   tp_debug_set_flags (g_getenv ("TP_DEBUG"));
 }
 
-
 void
 _tpl_debug_set_flags (TplDebugFlags new_flags)
 {
diff --git a/telepathy-logger/debug.h b/telepathy-logger/debug.h
new file mode 100644
index 0000000..641abeb
--- /dev/null
+++ b/telepathy-logger/debug.h
@@ -0,0 +1,32 @@
+/*
+ * Copyright (C) 2009 Collabora Ltd.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+ *
+ * Authors: Cosimo Alfarano <cosimo.alfarano at collabora.co.uk>
+ */
+
+#ifndef __TPL_DEBUG_H__
+#define __TPL_DEBUG_H__
+
+#include <glib.h>
+
+G_BEGIN_DECLS
+
+void tpl_debug_set_flags (const gchar *flags_string);
+
+G_END_DECLS
+
+#endif
diff --git a/telepathy-logger/telepathy-logger.h b/telepathy-logger/telepathy-logger.h
index 54d42d8..10578de 100644
--- a/telepathy-logger/telepathy-logger.h
+++ b/telepathy-logger/telepathy-logger.h
@@ -21,6 +21,7 @@
 #ifndef __TELEPATHY_LOGGER_H__
 #define __TELEPATHY_LOGGER_H__
 
+#include <telepathy-logger/debug.h>
 #include <telepathy-logger/entity.h>
 #include <telepathy-logger/text-event.h>
 #include <telepathy-logger/call-event.h>



More information about the telepathy-commits mailing list