Mercurial > pidgin
annotate src/debug.c @ 13236:0fa8153beebf
[gaim-migrate @ 15602]
SF patch 1413727 by sadrul
Adds a 'notify only when nick is said' to the notify in chats option. I
decided to tab the option in to make it look like it belonged to the option
above it more. Feel free to think it's horrible and remove the tab.
committer: Tailor Script <tailor@pidgin.im>
| author | Etan Reisner <pidgin@unreliablesource.net> |
|---|---|
| date | Sun, 12 Feb 2006 04:22:16 +0000 |
| parents | e1e5462b7d81 |
| children | 756c3d7177d9 |
| rev | line source |
|---|---|
| 5212 | 1 /** |
| 2 * @file debug.c Debug API | |
| 3 * @ingroup core | |
| 4 * | |
| 5 * gaim | |
| 6 * | |
| 8046 | 7 * Gaim is the legal property of its developers, whose names are too numerous |
| 8 * to list here. Please refer to the COPYRIGHT file distributed with this | |
| 9 * source distribution. | |
|
6483
565339a6eb86
[gaim-migrate @ 6997]
Christian Hammond <chipx86@chipx86.com>
parents:
5212
diff
changeset
|
10 * |
| 5212 | 11 * This program is free software; you can redistribute it and/or modify |
| 12 * it under the terms of the GNU General Public License as published by | |
| 13 * the Free Software Foundation; either version 2 of the License, or | |
| 14 * (at your option) any later version. | |
| 15 * | |
| 16 * This program is distributed in the hope that it will be useful, | |
| 17 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
| 19 * GNU General Public License for more details. | |
| 20 * | |
| 21 * You should have received a copy of the GNU General Public License | |
| 22 * along with this program; if not, write to the Free Software | |
| 23 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
| 24 */ | |
| 25 #include "debug.h" | |
| 10307 | 26 #include "internal.h" |
| 27 #include "prefs.h" | |
|
13104
e1e5462b7d81
[gaim-migrate @ 15466]
Richard Laager <rlaager@wiktel.com>
parents:
11504
diff
changeset
|
28 #include "util.h" |
| 5212 | 29 |
| 30 static GaimDebugUiOps *debug_ui_ops = NULL; | |
| 31 | |
| 10307 | 32 /* |
| 33 * This determines whether debug info should be written to the | |
| 34 * console or not. | |
| 35 * | |
| 36 * It doesn't make sense to make this a normal Gaim preference | |
| 37 * because it's a command line option. This will always be FALSE, | |
| 38 * unless the user explicitly started Gaim with the -d flag. | |
| 39 * It doesn't matter what this value was the last time Gaim was | |
| 40 * started, so it doesn't make sense to save it in prefs. | |
| 41 */ | |
| 42 static gboolean debug_enabled = FALSE; | |
| 43 | |
|
11504
921f64947cad
[gaim-migrate @ 13749]
Richard Laager <rlaager@wiktel.com>
parents:
11256
diff
changeset
|
44 static void |
| 5212 | 45 gaim_debug_vargs(GaimDebugLevel level, const char *category, |
| 46 const char *format, va_list args) | |
| 47 { | |
| 48 GaimDebugUiOps *ops; | |
| 49 | |
| 50 g_return_if_fail(level != GAIM_DEBUG_ALL); | |
| 51 g_return_if_fail(format != NULL); | |
| 52 | |
| 10307 | 53 if (debug_enabled) { |
| 54 gchar *arg_s, *ts_s; | |
| 55 | |
| 56 arg_s = g_strdup_vprintf(format, args); | |
| 57 | |
| 10448 | 58 if ((category != NULL) && |
| 59 (gaim_prefs_exists("/core/debug/timestamps")) && | |
| 60 (gaim_prefs_get_bool("/core/debug/timestamps"))) { | |
|
13104
e1e5462b7d81
[gaim-migrate @ 15466]
Richard Laager <rlaager@wiktel.com>
parents:
11504
diff
changeset
|
61 const char *mdate; |
| 10307 | 62 |
| 63 time_t mtime = time(NULL); | |
|
13104
e1e5462b7d81
[gaim-migrate @ 15466]
Richard Laager <rlaager@wiktel.com>
parents:
11504
diff
changeset
|
64 mdate = gaim_utf8_strftime("%H:%M:%S", localtime(&mtime)); |
| 10307 | 65 ts_s = g_strdup_printf("(%s) ", mdate); |
| 66 } else { | |
| 67 ts_s = g_strdup(""); | |
| 68 } | |
| 69 | |
| 70 if (category == NULL) | |
| 71 g_print("%s%s", ts_s, arg_s); | |
| 72 else | |
| 73 g_print("%s%s: %s", ts_s, category, arg_s); | |
| 74 | |
| 75 g_free(arg_s); | |
| 76 g_free(ts_s); | |
| 77 } | |
| 78 | |
|
7035
feb3d21a7794
[gaim-migrate @ 7598]
Christian Hammond <chipx86@chipx86.com>
parents:
6721
diff
changeset
|
79 ops = gaim_debug_get_ui_ops(); |
| 5212 | 80 |
| 81 if (ops != NULL && ops->print != NULL) | |
| 82 ops->print(level, category, format, args); | |
| 83 } | |
| 84 | |
| 85 void | |
| 86 gaim_debug(GaimDebugLevel level, const char *category, | |
| 87 const char *format, ...) | |
| 88 { | |
| 89 va_list args; | |
| 90 | |
| 91 g_return_if_fail(level != GAIM_DEBUG_ALL); | |
| 92 g_return_if_fail(format != NULL); | |
| 93 | |
| 94 va_start(args, format); | |
| 95 gaim_debug_vargs(level, category, format, args); | |
| 96 va_end(args); | |
| 97 } | |
| 98 | |
| 99 void | |
|
6721
acc4376ce062
[gaim-migrate @ 7248]
Christian Hammond <chipx86@chipx86.com>
parents:
6483
diff
changeset
|
100 gaim_debug_misc(const char *category, const char *format, ...) |
|
acc4376ce062
[gaim-migrate @ 7248]
Christian Hammond <chipx86@chipx86.com>
parents:
6483
diff
changeset
|
101 { |
|
acc4376ce062
[gaim-migrate @ 7248]
Christian Hammond <chipx86@chipx86.com>
parents:
6483
diff
changeset
|
102 va_list args; |
|
acc4376ce062
[gaim-migrate @ 7248]
Christian Hammond <chipx86@chipx86.com>
parents:
6483
diff
changeset
|
103 |
|
acc4376ce062
[gaim-migrate @ 7248]
Christian Hammond <chipx86@chipx86.com>
parents:
6483
diff
changeset
|
104 g_return_if_fail(format != NULL); |
|
acc4376ce062
[gaim-migrate @ 7248]
Christian Hammond <chipx86@chipx86.com>
parents:
6483
diff
changeset
|
105 |
|
acc4376ce062
[gaim-migrate @ 7248]
Christian Hammond <chipx86@chipx86.com>
parents:
6483
diff
changeset
|
106 va_start(args, format); |
|
acc4376ce062
[gaim-migrate @ 7248]
Christian Hammond <chipx86@chipx86.com>
parents:
6483
diff
changeset
|
107 gaim_debug_vargs(GAIM_DEBUG_MISC, category, format, args); |
|
acc4376ce062
[gaim-migrate @ 7248]
Christian Hammond <chipx86@chipx86.com>
parents:
6483
diff
changeset
|
108 va_end(args); |
|
acc4376ce062
[gaim-migrate @ 7248]
Christian Hammond <chipx86@chipx86.com>
parents:
6483
diff
changeset
|
109 } |
|
acc4376ce062
[gaim-migrate @ 7248]
Christian Hammond <chipx86@chipx86.com>
parents:
6483
diff
changeset
|
110 |
|
acc4376ce062
[gaim-migrate @ 7248]
Christian Hammond <chipx86@chipx86.com>
parents:
6483
diff
changeset
|
111 void |
|
acc4376ce062
[gaim-migrate @ 7248]
Christian Hammond <chipx86@chipx86.com>
parents:
6483
diff
changeset
|
112 gaim_debug_info(const char *category, const char *format, ...) |
|
acc4376ce062
[gaim-migrate @ 7248]
Christian Hammond <chipx86@chipx86.com>
parents:
6483
diff
changeset
|
113 { |
|
acc4376ce062
[gaim-migrate @ 7248]
Christian Hammond <chipx86@chipx86.com>
parents:
6483
diff
changeset
|
114 va_list args; |
|
acc4376ce062
[gaim-migrate @ 7248]
Christian Hammond <chipx86@chipx86.com>
parents:
6483
diff
changeset
|
115 |
|
acc4376ce062
[gaim-migrate @ 7248]
Christian Hammond <chipx86@chipx86.com>
parents:
6483
diff
changeset
|
116 g_return_if_fail(format != NULL); |
|
acc4376ce062
[gaim-migrate @ 7248]
Christian Hammond <chipx86@chipx86.com>
parents:
6483
diff
changeset
|
117 |
|
acc4376ce062
[gaim-migrate @ 7248]
Christian Hammond <chipx86@chipx86.com>
parents:
6483
diff
changeset
|
118 va_start(args, format); |
|
acc4376ce062
[gaim-migrate @ 7248]
Christian Hammond <chipx86@chipx86.com>
parents:
6483
diff
changeset
|
119 gaim_debug_vargs(GAIM_DEBUG_INFO, category, format, args); |
|
acc4376ce062
[gaim-migrate @ 7248]
Christian Hammond <chipx86@chipx86.com>
parents:
6483
diff
changeset
|
120 va_end(args); |
|
acc4376ce062
[gaim-migrate @ 7248]
Christian Hammond <chipx86@chipx86.com>
parents:
6483
diff
changeset
|
121 } |
|
acc4376ce062
[gaim-migrate @ 7248]
Christian Hammond <chipx86@chipx86.com>
parents:
6483
diff
changeset
|
122 |
|
acc4376ce062
[gaim-migrate @ 7248]
Christian Hammond <chipx86@chipx86.com>
parents:
6483
diff
changeset
|
123 void |
|
acc4376ce062
[gaim-migrate @ 7248]
Christian Hammond <chipx86@chipx86.com>
parents:
6483
diff
changeset
|
124 gaim_debug_warning(const char *category, const char *format, ...) |
|
acc4376ce062
[gaim-migrate @ 7248]
Christian Hammond <chipx86@chipx86.com>
parents:
6483
diff
changeset
|
125 { |
|
acc4376ce062
[gaim-migrate @ 7248]
Christian Hammond <chipx86@chipx86.com>
parents:
6483
diff
changeset
|
126 va_list args; |
|
acc4376ce062
[gaim-migrate @ 7248]
Christian Hammond <chipx86@chipx86.com>
parents:
6483
diff
changeset
|
127 |
|
acc4376ce062
[gaim-migrate @ 7248]
Christian Hammond <chipx86@chipx86.com>
parents:
6483
diff
changeset
|
128 g_return_if_fail(format != NULL); |
|
acc4376ce062
[gaim-migrate @ 7248]
Christian Hammond <chipx86@chipx86.com>
parents:
6483
diff
changeset
|
129 |
|
acc4376ce062
[gaim-migrate @ 7248]
Christian Hammond <chipx86@chipx86.com>
parents:
6483
diff
changeset
|
130 va_start(args, format); |
|
acc4376ce062
[gaim-migrate @ 7248]
Christian Hammond <chipx86@chipx86.com>
parents:
6483
diff
changeset
|
131 gaim_debug_vargs(GAIM_DEBUG_WARNING, category, format, args); |
|
acc4376ce062
[gaim-migrate @ 7248]
Christian Hammond <chipx86@chipx86.com>
parents:
6483
diff
changeset
|
132 va_end(args); |
|
acc4376ce062
[gaim-migrate @ 7248]
Christian Hammond <chipx86@chipx86.com>
parents:
6483
diff
changeset
|
133 } |
|
acc4376ce062
[gaim-migrate @ 7248]
Christian Hammond <chipx86@chipx86.com>
parents:
6483
diff
changeset
|
134 |
|
acc4376ce062
[gaim-migrate @ 7248]
Christian Hammond <chipx86@chipx86.com>
parents:
6483
diff
changeset
|
135 void |
|
acc4376ce062
[gaim-migrate @ 7248]
Christian Hammond <chipx86@chipx86.com>
parents:
6483
diff
changeset
|
136 gaim_debug_error(const char *category, const char *format, ...) |
|
acc4376ce062
[gaim-migrate @ 7248]
Christian Hammond <chipx86@chipx86.com>
parents:
6483
diff
changeset
|
137 { |
|
acc4376ce062
[gaim-migrate @ 7248]
Christian Hammond <chipx86@chipx86.com>
parents:
6483
diff
changeset
|
138 va_list args; |
|
acc4376ce062
[gaim-migrate @ 7248]
Christian Hammond <chipx86@chipx86.com>
parents:
6483
diff
changeset
|
139 |
|
acc4376ce062
[gaim-migrate @ 7248]
Christian Hammond <chipx86@chipx86.com>
parents:
6483
diff
changeset
|
140 g_return_if_fail(format != NULL); |
|
acc4376ce062
[gaim-migrate @ 7248]
Christian Hammond <chipx86@chipx86.com>
parents:
6483
diff
changeset
|
141 |
|
acc4376ce062
[gaim-migrate @ 7248]
Christian Hammond <chipx86@chipx86.com>
parents:
6483
diff
changeset
|
142 va_start(args, format); |
|
acc4376ce062
[gaim-migrate @ 7248]
Christian Hammond <chipx86@chipx86.com>
parents:
6483
diff
changeset
|
143 gaim_debug_vargs(GAIM_DEBUG_ERROR, category, format, args); |
|
acc4376ce062
[gaim-migrate @ 7248]
Christian Hammond <chipx86@chipx86.com>
parents:
6483
diff
changeset
|
144 va_end(args); |
|
acc4376ce062
[gaim-migrate @ 7248]
Christian Hammond <chipx86@chipx86.com>
parents:
6483
diff
changeset
|
145 } |
|
acc4376ce062
[gaim-migrate @ 7248]
Christian Hammond <chipx86@chipx86.com>
parents:
6483
diff
changeset
|
146 |
|
acc4376ce062
[gaim-migrate @ 7248]
Christian Hammond <chipx86@chipx86.com>
parents:
6483
diff
changeset
|
147 void |
|
acc4376ce062
[gaim-migrate @ 7248]
Christian Hammond <chipx86@chipx86.com>
parents:
6483
diff
changeset
|
148 gaim_debug_fatal(const char *category, const char *format, ...) |
|
acc4376ce062
[gaim-migrate @ 7248]
Christian Hammond <chipx86@chipx86.com>
parents:
6483
diff
changeset
|
149 { |
|
acc4376ce062
[gaim-migrate @ 7248]
Christian Hammond <chipx86@chipx86.com>
parents:
6483
diff
changeset
|
150 va_list args; |
|
acc4376ce062
[gaim-migrate @ 7248]
Christian Hammond <chipx86@chipx86.com>
parents:
6483
diff
changeset
|
151 |
|
acc4376ce062
[gaim-migrate @ 7248]
Christian Hammond <chipx86@chipx86.com>
parents:
6483
diff
changeset
|
152 g_return_if_fail(format != NULL); |
|
acc4376ce062
[gaim-migrate @ 7248]
Christian Hammond <chipx86@chipx86.com>
parents:
6483
diff
changeset
|
153 |
|
acc4376ce062
[gaim-migrate @ 7248]
Christian Hammond <chipx86@chipx86.com>
parents:
6483
diff
changeset
|
154 va_start(args, format); |
|
acc4376ce062
[gaim-migrate @ 7248]
Christian Hammond <chipx86@chipx86.com>
parents:
6483
diff
changeset
|
155 gaim_debug_vargs(GAIM_DEBUG_FATAL, category, format, args); |
|
acc4376ce062
[gaim-migrate @ 7248]
Christian Hammond <chipx86@chipx86.com>
parents:
6483
diff
changeset
|
156 va_end(args); |
|
acc4376ce062
[gaim-migrate @ 7248]
Christian Hammond <chipx86@chipx86.com>
parents:
6483
diff
changeset
|
157 } |
|
acc4376ce062
[gaim-migrate @ 7248]
Christian Hammond <chipx86@chipx86.com>
parents:
6483
diff
changeset
|
158 |
|
acc4376ce062
[gaim-migrate @ 7248]
Christian Hammond <chipx86@chipx86.com>
parents:
6483
diff
changeset
|
159 void |
| 10307 | 160 gaim_debug_set_enabled(gboolean enabled) |
| 161 { | |
| 162 debug_enabled = enabled; | |
| 163 } | |
| 164 | |
| 165 gboolean | |
| 166 gaim_debug_is_enabled() | |
| 167 { | |
| 168 return debug_enabled; | |
| 169 } | |
| 170 | |
| 171 void | |
|
7035
feb3d21a7794
[gaim-migrate @ 7598]
Christian Hammond <chipx86@chipx86.com>
parents:
6721
diff
changeset
|
172 gaim_debug_set_ui_ops(GaimDebugUiOps *ops) |
| 5212 | 173 { |
| 174 debug_ui_ops = ops; | |
| 175 } | |
| 176 | |
| 177 GaimDebugUiOps * | |
|
7035
feb3d21a7794
[gaim-migrate @ 7598]
Christian Hammond <chipx86@chipx86.com>
parents:
6721
diff
changeset
|
178 gaim_debug_get_ui_ops(void) |
| 5212 | 179 { |
| 180 return debug_ui_ops; | |
| 181 } | |
| 10307 | 182 |
| 183 void | |
| 184 gaim_debug_init(void) | |
| 185 { | |
| 186 gaim_prefs_add_none("/core/debug"); | |
| 187 | |
| 188 /* | |
| 189 * This pref is currently used by both the console | |
| 190 * output and the debug window output. | |
| 191 */ | |
| 192 gaim_prefs_add_bool("/core/debug/timestamps", FALSE); | |
| 193 } |
