src/debug.c

changeset 13988
a178d3dcbb7f
parent 13105
8f9c66e4af87
equal deleted inserted replaced
13987:b5b1db6007b0 13988:a178d3dcbb7f
44 static void 44 static void
45 gaim_debug_vargs(GaimDebugLevel level, const char *category, 45 gaim_debug_vargs(GaimDebugLevel level, const char *category,
46 const char *format, va_list args) 46 const char *format, va_list args)
47 { 47 {
48 GaimDebugUiOps *ops; 48 GaimDebugUiOps *ops;
49 char *arg_s = NULL;
49 50
50 g_return_if_fail(level != GAIM_DEBUG_ALL); 51 g_return_if_fail(level != GAIM_DEBUG_ALL);
51 g_return_if_fail(format != NULL); 52 g_return_if_fail(format != NULL);
52 53
54 ops = gaim_debug_get_ui_ops();
55
56 if (!debug_enabled && ((ops == NULL) || (ops->print == NULL)))
57 return;
58
59 arg_s = g_strdup_vprintf(format, args);
60
53 if (debug_enabled) { 61 if (debug_enabled) {
54 gchar *arg_s, *ts_s; 62 gchar *ts_s;
55
56 arg_s = g_strdup_vprintf(format, args);
57 63
58 if ((category != NULL) && 64 if ((category != NULL) &&
59 (gaim_prefs_exists("/core/debug/timestamps")) && 65 (gaim_prefs_exists("/core/debug/timestamps")) &&
60 (gaim_prefs_get_bool("/core/debug/timestamps"))) { 66 (gaim_prefs_get_bool("/core/debug/timestamps"))) {
61 const char *mdate; 67 const char *mdate;
70 if (category == NULL) 76 if (category == NULL)
71 g_print("%s%s", ts_s, arg_s); 77 g_print("%s%s", ts_s, arg_s);
72 else 78 else
73 g_print("%s%s: %s", ts_s, category, arg_s); 79 g_print("%s%s: %s", ts_s, category, arg_s);
74 80
75 g_free(arg_s);
76 g_free(ts_s); 81 g_free(ts_s);
77 } 82 }
78 83
79 ops = gaim_debug_get_ui_ops(); 84 if (ops != NULL && ops->print != NULL)
85 ops->print(level, category, arg_s);
80 86
81 if (ops != NULL && ops->print != NULL) 87 g_free(arg_s);
82 ops->print(level, category, format, args);
83 } 88 }
84 89
85 void 90 void
86 gaim_debug(GaimDebugLevel level, const char *category, 91 gaim_debug(GaimDebugLevel level, const char *category,
87 const char *format, ...) 92 const char *format, ...)

mercurial