changeset 27379:a22ef93d6aec

Move the handling of PURPLE_UNSAFE_DEBUG to purple_debug_init(). Also add handling for PURPLE_VERBOSE_DEBUG, as Sadrul and I briefly discussed, which we should use instead of requiring building with the --enable-debug configure argument just to get extra output.
author John Bailey <rekkanoryo@rekkanoryo.org>
date Sat, 04 Jul 2009 19:01:16 +0000
parents c0b4ab2f4b9f
children e9279f0e551a
files libpurple/debug.c libpurple/debug.h
diffstat 2 files changed, 82 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/libpurple/debug.c	Sat Jul 04 17:19:00 2009 +0000
+++ b/libpurple/debug.c	Sat Jul 04 19:01:16 2009 +0000
@@ -36,12 +36,20 @@
  *
  * It doesn't make sense to make this a normal Purple preference
  * because it's a command line option.  This will always be FALSE,
- * unless the user explicitly started Purple with the -d flag.
+ * unless the user explicitly started the UI with the -d flag.
  * It doesn't matter what this value was the last time Purple was
  * started, so it doesn't make sense to save it in prefs.
  */
 static gboolean debug_enabled = FALSE;
 
+/*
+ * These determine whether verbose or unsafe debugging are desired.  I
+ * don't want to make these purple preferences because their values should
+ * not be remembered across instances of the UI.
+ */
+static gboolean debug_verbose = FALSE;
+static gboolean debug_unsafe = FALSE;
+
 static void
 purple_debug_vargs(PurpleDebugLevel level, const char *category,
 				 const char *format, va_list args)
@@ -175,6 +183,30 @@
 	debug_ui_ops = ops;
 }
 
+gboolean
+purple_debug_is_verbose()
+{
+	return debug_verbose;
+}
+
+void
+purple_debug_set_verbose(gboolean verbose)
+{
+	debug_verbose = verbose;
+}
+
+gboolean
+purple_debug_is_unsafe()
+{
+	return debug_unsafe;
+}
+
+void
+purple_debug_set_unsafe(gboolean unsafe)
+{
+	debug_unsafe = unsafe;
+}
+
 PurpleDebugUiOps *
 purple_debug_get_ui_ops(void)
 {
@@ -184,6 +216,13 @@
 void
 purple_debug_init(void)
 {
+	/* Read environment variables once per init */
+	if(g_getenv("PURPLE_UNSAFE_DEBUG"))
+		purple_debug_set_unsafe(TRUE);
+
+	if(g_getenv("PURPLE_VERBOSE_DEBUG"))
+		purple_debug_set_verbose(TRUE);
+
 	purple_prefs_add_none("/purple/debug");
 
 	/*
@@ -193,3 +232,4 @@
 	 */
 	purple_prefs_add_bool("/purple/debug/timestamps", TRUE);
 }
+
--- a/libpurple/debug.h	Sat Jul 04 17:19:00 2009 +0000
+++ b/libpurple/debug.h	Sat Jul 04 19:01:16 2009 +0000
@@ -151,10 +151,50 @@
 /**
  * Check if console debug output is enabled.
  *
- * @return TRUE if debuggin is enabled, FALSE if it is not.
+ * @return TRUE if debugging is enabled, FALSE if it is not.
  */
 gboolean purple_debug_is_enabled(void);
 
+/**
+ * Enable or disable verbose debugging.  This ordinarily should only be called
+ * by #purple_debug_init, but there are cases where this can be useful for
+ * plugins.
+ *
+ * @param verbose TRUE to enable verbose debugging or FALSE to disable it.
+ *
+ * @since 2.6.0
+ */
+void purple_debug_set_verbose(gboolean verbose);
+
+/**
+ * Check if verbose logging is enabled.
+ *
+ * @return TRUE if verbose debugging is enabled, FALSE if it is not.
+ *
+ * @since 2.6.0
+ */
+gboolean purple_debug_is_verbose(void);
+
+/**
+ * Enable or disable verbose debugging.  This ordinarily should only be called
+ * by #purple_debug_init, but there are cases where this can be useful for
+ * plugins.
+ *
+ * @param unsafe  TRUE to enable verbose debugging or FALSE to disable it.
+ *
+ * @since 2.6.0
+ */
+void purple_debug_set_unsafe(gboolean unsafe);
+
+/**
+ * Check if unsafe debugging is enabled.
+ *
+ * @return TRUE if verbose debugging is enabled, FALSE if it is not.
+ *
+ * @since 2.6.0
+ */
+gboolean purple_debug_is_unsafe(void);
+
 /*@}*/
 
 /**************************************************************************/