comparison libpurple/debug.c @ 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 6bf32c9e15a7
children f1437342cc0e
comparison
equal deleted inserted replaced
27378:c0b4ab2f4b9f 27379:a22ef93d6aec
34 * This determines whether debug info should be written to the 34 * This determines whether debug info should be written to the
35 * console or not. 35 * console or not.
36 * 36 *
37 * It doesn't make sense to make this a normal Purple preference 37 * It doesn't make sense to make this a normal Purple preference
38 * because it's a command line option. This will always be FALSE, 38 * because it's a command line option. This will always be FALSE,
39 * unless the user explicitly started Purple with the -d flag. 39 * unless the user explicitly started the UI with the -d flag.
40 * It doesn't matter what this value was the last time Purple was 40 * It doesn't matter what this value was the last time Purple was
41 * started, so it doesn't make sense to save it in prefs. 41 * started, so it doesn't make sense to save it in prefs.
42 */ 42 */
43 static gboolean debug_enabled = FALSE; 43 static gboolean debug_enabled = FALSE;
44
45 /*
46 * These determine whether verbose or unsafe debugging are desired. I
47 * don't want to make these purple preferences because their values should
48 * not be remembered across instances of the UI.
49 */
50 static gboolean debug_verbose = FALSE;
51 static gboolean debug_unsafe = FALSE;
44 52
45 static void 53 static void
46 purple_debug_vargs(PurpleDebugLevel level, const char *category, 54 purple_debug_vargs(PurpleDebugLevel level, const char *category,
47 const char *format, va_list args) 55 const char *format, va_list args)
48 { 56 {
173 purple_debug_set_ui_ops(PurpleDebugUiOps *ops) 181 purple_debug_set_ui_ops(PurpleDebugUiOps *ops)
174 { 182 {
175 debug_ui_ops = ops; 183 debug_ui_ops = ops;
176 } 184 }
177 185
186 gboolean
187 purple_debug_is_verbose()
188 {
189 return debug_verbose;
190 }
191
192 void
193 purple_debug_set_verbose(gboolean verbose)
194 {
195 debug_verbose = verbose;
196 }
197
198 gboolean
199 purple_debug_is_unsafe()
200 {
201 return debug_unsafe;
202 }
203
204 void
205 purple_debug_set_unsafe(gboolean unsafe)
206 {
207 debug_unsafe = unsafe;
208 }
209
178 PurpleDebugUiOps * 210 PurpleDebugUiOps *
179 purple_debug_get_ui_ops(void) 211 purple_debug_get_ui_ops(void)
180 { 212 {
181 return debug_ui_ops; 213 return debug_ui_ops;
182 } 214 }
183 215
184 void 216 void
185 purple_debug_init(void) 217 purple_debug_init(void)
186 { 218 {
219 /* Read environment variables once per init */
220 if(g_getenv("PURPLE_UNSAFE_DEBUG"))
221 purple_debug_set_unsafe(TRUE);
222
223 if(g_getenv("PURPLE_VERBOSE_DEBUG"))
224 purple_debug_set_verbose(TRUE);
225
187 purple_prefs_add_none("/purple/debug"); 226 purple_prefs_add_none("/purple/debug");
188 227
189 /* 228 /*
190 * This pref is obsolete and no longer referenced anywhere. It only 229 * This pref is obsolete and no longer referenced anywhere. It only
191 * survives here because it would be an API break if we removed it. 230 * survives here because it would be an API break if we removed it.
192 * Remove this when we get to 3.0.0 :) 231 * Remove this when we get to 3.0.0 :)
193 */ 232 */
194 purple_prefs_add_bool("/purple/debug/timestamps", TRUE); 233 purple_prefs_add_bool("/purple/debug/timestamps", TRUE);
195 } 234 }
235