Mercurial > pidgin
comparison libpurple/debug.c @ 15822:32c366eeeb99
sed -ie 's/gaim/purple/g'
| author | Sean Egan <seanegan@gmail.com> |
|---|---|
| date | Mon, 19 Mar 2007 07:01:17 +0000 |
| parents | 5fe8042783c1 |
| children | 6dc5dc83a61b |
comparison
equal
deleted
inserted
replaced
| 15821:84b0f9b23ede | 15822:32c366eeeb99 |
|---|---|
| 1 /** | 1 /** |
| 2 * @file debug.c Debug API | 2 * @file debug.c Debug API |
| 3 * @ingroup core | 3 * @ingroup core |
| 4 * | 4 * |
| 5 * gaim | 5 * purple |
| 6 * | 6 * |
| 7 * Gaim is the legal property of its developers, whose names are too numerous | 7 * Purple 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 | 8 * to list here. Please refer to the COPYRIGHT file distributed with this |
| 9 * source distribution. | 9 * source distribution. |
| 10 * | 10 * |
| 11 * This program is free software; you can redistribute it and/or modify | 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 | 12 * it under the terms of the GNU General Public License as published by |
| 25 #include "debug.h" | 25 #include "debug.h" |
| 26 #include "internal.h" | 26 #include "internal.h" |
| 27 #include "prefs.h" | 27 #include "prefs.h" |
| 28 #include "util.h" | 28 #include "util.h" |
| 29 | 29 |
| 30 static GaimDebugUiOps *debug_ui_ops = NULL; | 30 static PurpleDebugUiOps *debug_ui_ops = NULL; |
| 31 | 31 |
| 32 /* | 32 /* |
| 33 * This determines whether debug info should be written to the | 33 * This determines whether debug info should be written to the |
| 34 * console or not. | 34 * console or not. |
| 35 * | 35 * |
| 36 * It doesn't make sense to make this a normal Gaim preference | 36 * It doesn't make sense to make this a normal Purple preference |
| 37 * because it's a command line option. This will always be FALSE, | 37 * because it's a command line option. This will always be FALSE, |
| 38 * unless the user explicitly started Gaim with the -d flag. | 38 * unless the user explicitly started Purple with the -d flag. |
| 39 * It doesn't matter what this value was the last time Gaim was | 39 * It doesn't matter what this value was the last time Purple was |
| 40 * started, so it doesn't make sense to save it in prefs. | 40 * started, so it doesn't make sense to save it in prefs. |
| 41 */ | 41 */ |
| 42 static gboolean debug_enabled = FALSE; | 42 static gboolean debug_enabled = FALSE; |
| 43 | 43 |
| 44 static void | 44 static void |
| 45 gaim_debug_vargs(GaimDebugLevel level, const char *category, | 45 purple_debug_vargs(PurpleDebugLevel level, const char *category, |
| 46 const char *format, va_list args) | 46 const char *format, va_list args) |
| 47 { | 47 { |
| 48 GaimDebugUiOps *ops; | 48 PurpleDebugUiOps *ops; |
| 49 char *arg_s = NULL; | 49 char *arg_s = NULL; |
| 50 | 50 |
| 51 g_return_if_fail(level != GAIM_DEBUG_ALL); | 51 g_return_if_fail(level != PURPLE_DEBUG_ALL); |
| 52 g_return_if_fail(format != NULL); | 52 g_return_if_fail(format != NULL); |
| 53 | 53 |
| 54 ops = gaim_debug_get_ui_ops(); | 54 ops = purple_debug_get_ui_ops(); |
| 55 | 55 |
| 56 if (!debug_enabled && ((ops == NULL) || (ops->print == NULL))) | 56 if (!debug_enabled && ((ops == NULL) || (ops->print == NULL))) |
| 57 return; | 57 return; |
| 58 | 58 |
| 59 arg_s = g_strdup_vprintf(format, args); | 59 arg_s = g_strdup_vprintf(format, args); |
| 60 | 60 |
| 61 if (debug_enabled) { | 61 if (debug_enabled) { |
| 62 gchar *ts_s; | 62 gchar *ts_s; |
| 63 | 63 |
| 64 if ((category != NULL) && | 64 if ((category != NULL) && |
| 65 (gaim_prefs_exists("/core/debug/timestamps")) && | 65 (purple_prefs_exists("/core/debug/timestamps")) && |
| 66 (gaim_prefs_get_bool("/core/debug/timestamps"))) { | 66 (purple_prefs_get_bool("/core/debug/timestamps"))) { |
| 67 const char *mdate; | 67 const char *mdate; |
| 68 | 68 |
| 69 time_t mtime = time(NULL); | 69 time_t mtime = time(NULL); |
| 70 mdate = gaim_utf8_strftime("%H:%M:%S", localtime(&mtime)); | 70 mdate = purple_utf8_strftime("%H:%M:%S", localtime(&mtime)); |
| 71 ts_s = g_strdup_printf("(%s) ", mdate); | 71 ts_s = g_strdup_printf("(%s) ", mdate); |
| 72 } else { | 72 } else { |
| 73 ts_s = g_strdup(""); | 73 ts_s = g_strdup(""); |
| 74 } | 74 } |
| 75 | 75 |
| 86 | 86 |
| 87 g_free(arg_s); | 87 g_free(arg_s); |
| 88 } | 88 } |
| 89 | 89 |
| 90 void | 90 void |
| 91 gaim_debug(GaimDebugLevel level, const char *category, | 91 purple_debug(PurpleDebugLevel level, const char *category, |
| 92 const char *format, ...) | 92 const char *format, ...) |
| 93 { | 93 { |
| 94 va_list args; | 94 va_list args; |
| 95 | 95 |
| 96 g_return_if_fail(level != GAIM_DEBUG_ALL); | 96 g_return_if_fail(level != PURPLE_DEBUG_ALL); |
| 97 g_return_if_fail(format != NULL); | 97 g_return_if_fail(format != NULL); |
| 98 | 98 |
| 99 va_start(args, format); | 99 va_start(args, format); |
| 100 gaim_debug_vargs(level, category, format, args); | 100 purple_debug_vargs(level, category, format, args); |
| 101 va_end(args); | 101 va_end(args); |
| 102 } | 102 } |
| 103 | 103 |
| 104 void | 104 void |
| 105 gaim_debug_misc(const char *category, const char *format, ...) | 105 purple_debug_misc(const char *category, const char *format, ...) |
| 106 { | 106 { |
| 107 va_list args; | 107 va_list args; |
| 108 | 108 |
| 109 g_return_if_fail(format != NULL); | 109 g_return_if_fail(format != NULL); |
| 110 | 110 |
| 111 va_start(args, format); | 111 va_start(args, format); |
| 112 gaim_debug_vargs(GAIM_DEBUG_MISC, category, format, args); | 112 purple_debug_vargs(PURPLE_DEBUG_MISC, category, format, args); |
| 113 va_end(args); | 113 va_end(args); |
| 114 } | 114 } |
| 115 | 115 |
| 116 void | 116 void |
| 117 gaim_debug_info(const char *category, const char *format, ...) | 117 purple_debug_info(const char *category, const char *format, ...) |
| 118 { | 118 { |
| 119 va_list args; | 119 va_list args; |
| 120 | 120 |
| 121 g_return_if_fail(format != NULL); | 121 g_return_if_fail(format != NULL); |
| 122 | 122 |
| 123 va_start(args, format); | 123 va_start(args, format); |
| 124 gaim_debug_vargs(GAIM_DEBUG_INFO, category, format, args); | 124 purple_debug_vargs(PURPLE_DEBUG_INFO, category, format, args); |
| 125 va_end(args); | 125 va_end(args); |
| 126 } | 126 } |
| 127 | 127 |
| 128 void | 128 void |
| 129 gaim_debug_warning(const char *category, const char *format, ...) | 129 purple_debug_warning(const char *category, const char *format, ...) |
| 130 { | 130 { |
| 131 va_list args; | 131 va_list args; |
| 132 | 132 |
| 133 g_return_if_fail(format != NULL); | 133 g_return_if_fail(format != NULL); |
| 134 | 134 |
| 135 va_start(args, format); | 135 va_start(args, format); |
| 136 gaim_debug_vargs(GAIM_DEBUG_WARNING, category, format, args); | 136 purple_debug_vargs(PURPLE_DEBUG_WARNING, category, format, args); |
| 137 va_end(args); | 137 va_end(args); |
| 138 } | 138 } |
| 139 | 139 |
| 140 void | 140 void |
| 141 gaim_debug_error(const char *category, const char *format, ...) | 141 purple_debug_error(const char *category, const char *format, ...) |
| 142 { | 142 { |
| 143 va_list args; | 143 va_list args; |
| 144 | 144 |
| 145 g_return_if_fail(format != NULL); | 145 g_return_if_fail(format != NULL); |
| 146 | 146 |
| 147 va_start(args, format); | 147 va_start(args, format); |
| 148 gaim_debug_vargs(GAIM_DEBUG_ERROR, category, format, args); | 148 purple_debug_vargs(PURPLE_DEBUG_ERROR, category, format, args); |
| 149 va_end(args); | 149 va_end(args); |
| 150 } | 150 } |
| 151 | 151 |
| 152 void | 152 void |
| 153 gaim_debug_fatal(const char *category, const char *format, ...) | 153 purple_debug_fatal(const char *category, const char *format, ...) |
| 154 { | 154 { |
| 155 va_list args; | 155 va_list args; |
| 156 | 156 |
| 157 g_return_if_fail(format != NULL); | 157 g_return_if_fail(format != NULL); |
| 158 | 158 |
| 159 va_start(args, format); | 159 va_start(args, format); |
| 160 gaim_debug_vargs(GAIM_DEBUG_FATAL, category, format, args); | 160 purple_debug_vargs(PURPLE_DEBUG_FATAL, category, format, args); |
| 161 va_end(args); | 161 va_end(args); |
| 162 } | 162 } |
| 163 | 163 |
| 164 void | 164 void |
| 165 gaim_debug_set_enabled(gboolean enabled) | 165 purple_debug_set_enabled(gboolean enabled) |
| 166 { | 166 { |
| 167 debug_enabled = enabled; | 167 debug_enabled = enabled; |
| 168 } | 168 } |
| 169 | 169 |
| 170 gboolean | 170 gboolean |
| 171 gaim_debug_is_enabled() | 171 purple_debug_is_enabled() |
| 172 { | 172 { |
| 173 return debug_enabled; | 173 return debug_enabled; |
| 174 } | 174 } |
| 175 | 175 |
| 176 void | 176 void |
| 177 gaim_debug_set_ui_ops(GaimDebugUiOps *ops) | 177 purple_debug_set_ui_ops(PurpleDebugUiOps *ops) |
| 178 { | 178 { |
| 179 debug_ui_ops = ops; | 179 debug_ui_ops = ops; |
| 180 } | 180 } |
| 181 | 181 |
| 182 GaimDebugUiOps * | 182 PurpleDebugUiOps * |
| 183 gaim_debug_get_ui_ops(void) | 183 purple_debug_get_ui_ops(void) |
| 184 { | 184 { |
| 185 return debug_ui_ops; | 185 return debug_ui_ops; |
| 186 } | 186 } |
| 187 | 187 |
| 188 void | 188 void |
| 189 gaim_debug_init(void) | 189 purple_debug_init(void) |
| 190 { | 190 { |
| 191 gaim_prefs_add_none("/core/debug"); | 191 purple_prefs_add_none("/core/debug"); |
| 192 | 192 |
| 193 /* | 193 /* |
| 194 * This pref is currently used by both the console | 194 * This pref is currently used by both the console |
| 195 * output and the debug window output. | 195 * output and the debug window output. |
| 196 */ | 196 */ |
| 197 gaim_prefs_add_bool("/core/debug/timestamps", FALSE); | 197 purple_prefs_add_bool("/core/debug/timestamps", FALSE); |
| 198 } | 198 } |
