Sun, 23 Feb 2014 01:43:21 +0530
Use g_free as UiOps structures GBoxed free function
|
20147
66f05a854eee
applied changes from 8a731bbd0197fbcc91a705c2d8f528154216defa
Richard Laager <rlaager@pidgin.im>
parents:
19859
diff
changeset
|
1 | /* purple |
| 5212 | 2 | * |
| 15884 | 3 | * Purple is the legal property of its developers, whose names are too numerous |
| 8046 | 4 | * to list here. Please refer to the COPYRIGHT file distributed with this |
| 5 | * source distribution. | |
|
6483
d12ecdf8e489
[gaim-migrate @ 6997]
Christian Hammond <chipx86@chipx86.com>
parents:
5212
diff
changeset
|
6 | * |
| 5212 | 7 | * This program is free software; you can redistribute it and/or modify |
| 8 | * it under the terms of the GNU General Public License as published by | |
| 9 | * the Free Software Foundation; either version 2 of the License, or | |
| 10 | * (at your option) any later version. | |
| 11 | * | |
| 12 | * This program is distributed in the hope that it will be useful, | |
| 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
| 15 | * GNU General Public License for more details. | |
| 16 | * | |
| 17 | * You should have received a copy of the GNU General Public License | |
| 18 | * along with this program; if not, write to the Free Software | |
|
19859
71d37b57eff2
The FSF changed its address a while ago; our files were out of date.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
17318
diff
changeset
|
19 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA |
| 5212 | 20 | */ |
|
28981
4e3922ab4844
Include 'internal.h' before all other headers to make some non-gcc compilers happy.
Paul Aurich <darkrain42@pidgin.im>
parents:
27542
diff
changeset
|
21 | #include "internal.h" |
| 5212 | 22 | #include "debug.h" |
|
10307
f3ba80364053
[gaim-migrate @ 11497]
Mark Doliner <markdoliner@pidgin.im>
parents:
8046
diff
changeset
|
23 | #include "prefs.h" |
|
13105
8f9c66e4af87
[gaim-migrate @ 15466]
Richard Laager <rlaager@pidgin.im>
parents:
11504
diff
changeset
|
24 | #include "util.h" |
| 5212 | 25 | |
| 15884 | 26 | static PurpleDebugUiOps *debug_ui_ops = NULL; |
| 5212 | 27 | |
|
10307
f3ba80364053
[gaim-migrate @ 11497]
Mark Doliner <markdoliner@pidgin.im>
parents:
8046
diff
changeset
|
28 | /* |
|
f3ba80364053
[gaim-migrate @ 11497]
Mark Doliner <markdoliner@pidgin.im>
parents:
8046
diff
changeset
|
29 | * This determines whether debug info should be written to the |
|
f3ba80364053
[gaim-migrate @ 11497]
Mark Doliner <markdoliner@pidgin.im>
parents:
8046
diff
changeset
|
30 | * console or not. |
|
f3ba80364053
[gaim-migrate @ 11497]
Mark Doliner <markdoliner@pidgin.im>
parents:
8046
diff
changeset
|
31 | * |
| 15884 | 32 | * It doesn't make sense to make this a normal Purple preference |
|
10307
f3ba80364053
[gaim-migrate @ 11497]
Mark Doliner <markdoliner@pidgin.im>
parents:
8046
diff
changeset
|
33 | * because it's a command line option. This will always be FALSE, |
|
27542
a7acdc4ba23f
Move the handling of PURPLE_UNSAFE_DEBUG to purple_debug_init(). Also add
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
20147
diff
changeset
|
34 | * unless the user explicitly started the UI with the -d flag. |
| 15884 | 35 | * It doesn't matter what this value was the last time Purple was |
|
10307
f3ba80364053
[gaim-migrate @ 11497]
Mark Doliner <markdoliner@pidgin.im>
parents:
8046
diff
changeset
|
36 | * started, so it doesn't make sense to save it in prefs. |
|
f3ba80364053
[gaim-migrate @ 11497]
Mark Doliner <markdoliner@pidgin.im>
parents:
8046
diff
changeset
|
37 | */ |
|
f3ba80364053
[gaim-migrate @ 11497]
Mark Doliner <markdoliner@pidgin.im>
parents:
8046
diff
changeset
|
38 | static gboolean debug_enabled = FALSE; |
|
f3ba80364053
[gaim-migrate @ 11497]
Mark Doliner <markdoliner@pidgin.im>
parents:
8046
diff
changeset
|
39 | |
|
27542
a7acdc4ba23f
Move the handling of PURPLE_UNSAFE_DEBUG to purple_debug_init(). Also add
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
20147
diff
changeset
|
40 | /* |
|
a7acdc4ba23f
Move the handling of PURPLE_UNSAFE_DEBUG to purple_debug_init(). Also add
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
20147
diff
changeset
|
41 | * These determine whether verbose or unsafe debugging are desired. I |
|
a7acdc4ba23f
Move the handling of PURPLE_UNSAFE_DEBUG to purple_debug_init(). Also add
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
20147
diff
changeset
|
42 | * don't want to make these purple preferences because their values should |
|
a7acdc4ba23f
Move the handling of PURPLE_UNSAFE_DEBUG to purple_debug_init(). Also add
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
20147
diff
changeset
|
43 | * not be remembered across instances of the UI. |
|
a7acdc4ba23f
Move the handling of PURPLE_UNSAFE_DEBUG to purple_debug_init(). Also add
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
20147
diff
changeset
|
44 | */ |
|
a7acdc4ba23f
Move the handling of PURPLE_UNSAFE_DEBUG to purple_debug_init(). Also add
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
20147
diff
changeset
|
45 | static gboolean debug_verbose = FALSE; |
|
a7acdc4ba23f
Move the handling of PURPLE_UNSAFE_DEBUG to purple_debug_init(). Also add
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
20147
diff
changeset
|
46 | static gboolean debug_unsafe = FALSE; |
|
a7acdc4ba23f
Move the handling of PURPLE_UNSAFE_DEBUG to purple_debug_init(). Also add
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
20147
diff
changeset
|
47 | |
|
34296
d31a4f3b547e
Debug log: optional colored output and no need for add linefeed at the end of each message
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
32438
diff
changeset
|
48 | static gboolean debug_colored = FALSE; |
|
d31a4f3b547e
Debug log: optional colored output and no need for add linefeed at the end of each message
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
32438
diff
changeset
|
49 | |
|
11504
eabc708c2ea9
[gaim-migrate @ 13749]
Richard Laager <rlaager@pidgin.im>
parents:
11256
diff
changeset
|
50 | static void |
| 15884 | 51 | purple_debug_vargs(PurpleDebugLevel level, const char *category, |
| 5212 | 52 | const char *format, va_list args) |
| 53 | { | |
| 15884 | 54 | PurpleDebugUiOps *ops; |
|
13988
a178d3dcbb7f
[gaim-migrate @ 16445]
Mark Doliner <markdoliner@pidgin.im>
parents:
13105
diff
changeset
|
55 | char *arg_s = NULL; |
| 5212 | 56 | |
| 15884 | 57 | g_return_if_fail(level != PURPLE_DEBUG_ALL); |
| 5212 | 58 | g_return_if_fail(format != NULL); |
| 59 | ||
| 15884 | 60 | ops = purple_debug_get_ui_ops(); |
|
13988
a178d3dcbb7f
[gaim-migrate @ 16445]
Mark Doliner <markdoliner@pidgin.im>
parents:
13105
diff
changeset
|
61 | |
|
16044
257072807aa8
Add a whimpy ui op to the debug API that returns TRUE if debugging
Mark Doliner <markdoliner@pidgin.im>
parents:
15884
diff
changeset
|
62 | if (!debug_enabled && ((ops == NULL) || (ops->print == NULL) || |
|
257072807aa8
Add a whimpy ui op to the debug API that returns TRUE if debugging
Mark Doliner <markdoliner@pidgin.im>
parents:
15884
diff
changeset
|
63 | (ops->is_enabled && !ops->is_enabled(level, category)))) |
|
13988
a178d3dcbb7f
[gaim-migrate @ 16445]
Mark Doliner <markdoliner@pidgin.im>
parents:
13105
diff
changeset
|
64 | return; |
|
a178d3dcbb7f
[gaim-migrate @ 16445]
Mark Doliner <markdoliner@pidgin.im>
parents:
13105
diff
changeset
|
65 | |
|
a178d3dcbb7f
[gaim-migrate @ 16445]
Mark Doliner <markdoliner@pidgin.im>
parents:
13105
diff
changeset
|
66 | arg_s = g_strdup_vprintf(format, args); |
|
34296
d31a4f3b547e
Debug log: optional colored output and no need for add linefeed at the end of each message
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
32438
diff
changeset
|
67 | g_strchomp(arg_s); /* strip trailing linefeeds */ |
|
13988
a178d3dcbb7f
[gaim-migrate @ 16445]
Mark Doliner <markdoliner@pidgin.im>
parents:
13105
diff
changeset
|
68 | |
|
10307
f3ba80364053
[gaim-migrate @ 11497]
Mark Doliner <markdoliner@pidgin.im>
parents:
8046
diff
changeset
|
69 | if (debug_enabled) { |
|
13988
a178d3dcbb7f
[gaim-migrate @ 16445]
Mark Doliner <markdoliner@pidgin.im>
parents:
13105
diff
changeset
|
70 | gchar *ts_s; |
|
17040
cb33027a36e4
Force timestamps always on for debug log and debug window. Making this
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16478
diff
changeset
|
71 | const char *mdate; |
|
cb33027a36e4
Force timestamps always on for debug log and debug window. Making this
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16478
diff
changeset
|
72 | time_t mtime = time(NULL); |
|
34296
d31a4f3b547e
Debug log: optional colored output and no need for add linefeed at the end of each message
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
32438
diff
changeset
|
73 | const gchar *format_pre, *format_post; |
|
10307
f3ba80364053
[gaim-migrate @ 11497]
Mark Doliner <markdoliner@pidgin.im>
parents:
8046
diff
changeset
|
74 | |
|
34296
d31a4f3b547e
Debug log: optional colored output and no need for add linefeed at the end of each message
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
32438
diff
changeset
|
75 | format_pre = ""; |
|
d31a4f3b547e
Debug log: optional colored output and no need for add linefeed at the end of each message
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
32438
diff
changeset
|
76 | format_post = ""; |
|
d31a4f3b547e
Debug log: optional colored output and no need for add linefeed at the end of each message
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
32438
diff
changeset
|
77 | |
|
d31a4f3b547e
Debug log: optional colored output and no need for add linefeed at the end of each message
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
32438
diff
changeset
|
78 | if (!debug_colored) |
|
d31a4f3b547e
Debug log: optional colored output and no need for add linefeed at the end of each message
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
32438
diff
changeset
|
79 | format_pre = ""; |
|
d31a4f3b547e
Debug log: optional colored output and no need for add linefeed at the end of each message
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
32438
diff
changeset
|
80 | else if (level == PURPLE_DEBUG_MISC) |
|
d31a4f3b547e
Debug log: optional colored output and no need for add linefeed at the end of each message
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
32438
diff
changeset
|
81 | format_pre = "\033[0;37m"; |
|
d31a4f3b547e
Debug log: optional colored output and no need for add linefeed at the end of each message
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
32438
diff
changeset
|
82 | else if (level == PURPLE_DEBUG_INFO) |
|
d31a4f3b547e
Debug log: optional colored output and no need for add linefeed at the end of each message
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
32438
diff
changeset
|
83 | format_pre = ""; |
|
d31a4f3b547e
Debug log: optional colored output and no need for add linefeed at the end of each message
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
32438
diff
changeset
|
84 | else if (level == PURPLE_DEBUG_WARNING) |
|
d31a4f3b547e
Debug log: optional colored output and no need for add linefeed at the end of each message
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
32438
diff
changeset
|
85 | format_pre = "\033[0;33m"; |
|
d31a4f3b547e
Debug log: optional colored output and no need for add linefeed at the end of each message
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
32438
diff
changeset
|
86 | else if (level == PURPLE_DEBUG_ERROR) |
|
d31a4f3b547e
Debug log: optional colored output and no need for add linefeed at the end of each message
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
32438
diff
changeset
|
87 | format_pre = "\033[1;31m"; |
|
d31a4f3b547e
Debug log: optional colored output and no need for add linefeed at the end of each message
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
32438
diff
changeset
|
88 | else if (level == PURPLE_DEBUG_FATAL) |
|
d31a4f3b547e
Debug log: optional colored output and no need for add linefeed at the end of each message
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
32438
diff
changeset
|
89 | format_pre = "\033[1;33;41m"; |
|
d31a4f3b547e
Debug log: optional colored output and no need for add linefeed at the end of each message
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
32438
diff
changeset
|
90 | |
|
d31a4f3b547e
Debug log: optional colored output and no need for add linefeed at the end of each message
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
32438
diff
changeset
|
91 | if (format_pre[0] != '\0') |
|
d31a4f3b547e
Debug log: optional colored output and no need for add linefeed at the end of each message
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
32438
diff
changeset
|
92 | format_post = "\033[0m"; |
|
17040
cb33027a36e4
Force timestamps always on for debug log and debug window. Making this
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16478
diff
changeset
|
93 | |
|
cb33027a36e4
Force timestamps always on for debug log and debug window. Making this
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16478
diff
changeset
|
94 | mdate = purple_utf8_strftime("%H:%M:%S", localtime(&mtime)); |
|
cb33027a36e4
Force timestamps always on for debug log and debug window. Making this
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16478
diff
changeset
|
95 | ts_s = g_strdup_printf("(%s) ", mdate); |
|
10307
f3ba80364053
[gaim-migrate @ 11497]
Mark Doliner <markdoliner@pidgin.im>
parents:
8046
diff
changeset
|
96 | |
|
f3ba80364053
[gaim-migrate @ 11497]
Mark Doliner <markdoliner@pidgin.im>
parents:
8046
diff
changeset
|
97 | if (category == NULL) |
|
34296
d31a4f3b547e
Debug log: optional colored output and no need for add linefeed at the end of each message
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
32438
diff
changeset
|
98 | g_print("%s%s%s%s\n", format_pre, ts_s, arg_s, format_post); |
|
10307
f3ba80364053
[gaim-migrate @ 11497]
Mark Doliner <markdoliner@pidgin.im>
parents:
8046
diff
changeset
|
99 | else |
|
34296
d31a4f3b547e
Debug log: optional colored output and no need for add linefeed at the end of each message
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
32438
diff
changeset
|
100 | g_print("%s%s%s: %s%s\n", format_pre, ts_s, category, arg_s, format_post); |
|
10307
f3ba80364053
[gaim-migrate @ 11497]
Mark Doliner <markdoliner@pidgin.im>
parents:
8046
diff
changeset
|
101 | |
|
f3ba80364053
[gaim-migrate @ 11497]
Mark Doliner <markdoliner@pidgin.im>
parents:
8046
diff
changeset
|
102 | g_free(ts_s); |
|
f3ba80364053
[gaim-migrate @ 11497]
Mark Doliner <markdoliner@pidgin.im>
parents:
8046
diff
changeset
|
103 | } |
|
f3ba80364053
[gaim-migrate @ 11497]
Mark Doliner <markdoliner@pidgin.im>
parents:
8046
diff
changeset
|
104 | |
|
13988
a178d3dcbb7f
[gaim-migrate @ 16445]
Mark Doliner <markdoliner@pidgin.im>
parents:
13105
diff
changeset
|
105 | if (ops != NULL && ops->print != NULL) |
|
a178d3dcbb7f
[gaim-migrate @ 16445]
Mark Doliner <markdoliner@pidgin.im>
parents:
13105
diff
changeset
|
106 | ops->print(level, category, arg_s); |
| 5212 | 107 | |
|
13988
a178d3dcbb7f
[gaim-migrate @ 16445]
Mark Doliner <markdoliner@pidgin.im>
parents:
13105
diff
changeset
|
108 | g_free(arg_s); |
| 5212 | 109 | } |
| 110 | ||
| 111 | void | |
| 15884 | 112 | purple_debug(PurpleDebugLevel level, const char *category, |
| 5212 | 113 | const char *format, ...) |
| 114 | { | |
| 115 | va_list args; | |
| 116 | ||
| 15884 | 117 | g_return_if_fail(level != PURPLE_DEBUG_ALL); |
| 5212 | 118 | g_return_if_fail(format != NULL); |
| 119 | ||
| 120 | va_start(args, format); | |
| 15884 | 121 | purple_debug_vargs(level, category, format, args); |
| 5212 | 122 | va_end(args); |
| 123 | } | |
| 124 | ||
| 125 | void | |
| 15884 | 126 | purple_debug_misc(const char *category, const char *format, ...) |
|
6721
41d2d86860f3
[gaim-migrate @ 7248]
Christian Hammond <chipx86@chipx86.com>
parents:
6483
diff
changeset
|
127 | { |
|
41d2d86860f3
[gaim-migrate @ 7248]
Christian Hammond <chipx86@chipx86.com>
parents:
6483
diff
changeset
|
128 | va_list args; |
|
41d2d86860f3
[gaim-migrate @ 7248]
Christian Hammond <chipx86@chipx86.com>
parents:
6483
diff
changeset
|
129 | |
|
41d2d86860f3
[gaim-migrate @ 7248]
Christian Hammond <chipx86@chipx86.com>
parents:
6483
diff
changeset
|
130 | g_return_if_fail(format != NULL); |
|
41d2d86860f3
[gaim-migrate @ 7248]
Christian Hammond <chipx86@chipx86.com>
parents:
6483
diff
changeset
|
131 | |
|
41d2d86860f3
[gaim-migrate @ 7248]
Christian Hammond <chipx86@chipx86.com>
parents:
6483
diff
changeset
|
132 | va_start(args, format); |
| 15884 | 133 | purple_debug_vargs(PURPLE_DEBUG_MISC, category, format, args); |
|
6721
41d2d86860f3
[gaim-migrate @ 7248]
Christian Hammond <chipx86@chipx86.com>
parents:
6483
diff
changeset
|
134 | va_end(args); |
|
41d2d86860f3
[gaim-migrate @ 7248]
Christian Hammond <chipx86@chipx86.com>
parents:
6483
diff
changeset
|
135 | } |
|
41d2d86860f3
[gaim-migrate @ 7248]
Christian Hammond <chipx86@chipx86.com>
parents:
6483
diff
changeset
|
136 | |
|
41d2d86860f3
[gaim-migrate @ 7248]
Christian Hammond <chipx86@chipx86.com>
parents:
6483
diff
changeset
|
137 | void |
| 15884 | 138 | purple_debug_info(const char *category, const char *format, ...) |
|
6721
41d2d86860f3
[gaim-migrate @ 7248]
Christian Hammond <chipx86@chipx86.com>
parents:
6483
diff
changeset
|
139 | { |
|
41d2d86860f3
[gaim-migrate @ 7248]
Christian Hammond <chipx86@chipx86.com>
parents:
6483
diff
changeset
|
140 | va_list args; |
|
41d2d86860f3
[gaim-migrate @ 7248]
Christian Hammond <chipx86@chipx86.com>
parents:
6483
diff
changeset
|
141 | |
|
41d2d86860f3
[gaim-migrate @ 7248]
Christian Hammond <chipx86@chipx86.com>
parents:
6483
diff
changeset
|
142 | g_return_if_fail(format != NULL); |
|
41d2d86860f3
[gaim-migrate @ 7248]
Christian Hammond <chipx86@chipx86.com>
parents:
6483
diff
changeset
|
143 | |
|
41d2d86860f3
[gaim-migrate @ 7248]
Christian Hammond <chipx86@chipx86.com>
parents:
6483
diff
changeset
|
144 | va_start(args, format); |
| 15884 | 145 | purple_debug_vargs(PURPLE_DEBUG_INFO, category, format, args); |
|
6721
41d2d86860f3
[gaim-migrate @ 7248]
Christian Hammond <chipx86@chipx86.com>
parents:
6483
diff
changeset
|
146 | va_end(args); |
|
41d2d86860f3
[gaim-migrate @ 7248]
Christian Hammond <chipx86@chipx86.com>
parents:
6483
diff
changeset
|
147 | } |
|
41d2d86860f3
[gaim-migrate @ 7248]
Christian Hammond <chipx86@chipx86.com>
parents:
6483
diff
changeset
|
148 | |
|
41d2d86860f3
[gaim-migrate @ 7248]
Christian Hammond <chipx86@chipx86.com>
parents:
6483
diff
changeset
|
149 | void |
| 15884 | 150 | purple_debug_warning(const char *category, const char *format, ...) |
|
6721
41d2d86860f3
[gaim-migrate @ 7248]
Christian Hammond <chipx86@chipx86.com>
parents:
6483
diff
changeset
|
151 | { |
|
41d2d86860f3
[gaim-migrate @ 7248]
Christian Hammond <chipx86@chipx86.com>
parents:
6483
diff
changeset
|
152 | va_list args; |
|
41d2d86860f3
[gaim-migrate @ 7248]
Christian Hammond <chipx86@chipx86.com>
parents:
6483
diff
changeset
|
153 | |
|
41d2d86860f3
[gaim-migrate @ 7248]
Christian Hammond <chipx86@chipx86.com>
parents:
6483
diff
changeset
|
154 | g_return_if_fail(format != NULL); |
|
41d2d86860f3
[gaim-migrate @ 7248]
Christian Hammond <chipx86@chipx86.com>
parents:
6483
diff
changeset
|
155 | |
|
41d2d86860f3
[gaim-migrate @ 7248]
Christian Hammond <chipx86@chipx86.com>
parents:
6483
diff
changeset
|
156 | va_start(args, format); |
| 15884 | 157 | purple_debug_vargs(PURPLE_DEBUG_WARNING, category, format, args); |
|
6721
41d2d86860f3
[gaim-migrate @ 7248]
Christian Hammond <chipx86@chipx86.com>
parents:
6483
diff
changeset
|
158 | va_end(args); |
|
41d2d86860f3
[gaim-migrate @ 7248]
Christian Hammond <chipx86@chipx86.com>
parents:
6483
diff
changeset
|
159 | } |
|
41d2d86860f3
[gaim-migrate @ 7248]
Christian Hammond <chipx86@chipx86.com>
parents:
6483
diff
changeset
|
160 | |
|
41d2d86860f3
[gaim-migrate @ 7248]
Christian Hammond <chipx86@chipx86.com>
parents:
6483
diff
changeset
|
161 | void |
| 15884 | 162 | purple_debug_error(const char *category, const char *format, ...) |
|
6721
41d2d86860f3
[gaim-migrate @ 7248]
Christian Hammond <chipx86@chipx86.com>
parents:
6483
diff
changeset
|
163 | { |
|
41d2d86860f3
[gaim-migrate @ 7248]
Christian Hammond <chipx86@chipx86.com>
parents:
6483
diff
changeset
|
164 | va_list args; |
|
41d2d86860f3
[gaim-migrate @ 7248]
Christian Hammond <chipx86@chipx86.com>
parents:
6483
diff
changeset
|
165 | |
|
41d2d86860f3
[gaim-migrate @ 7248]
Christian Hammond <chipx86@chipx86.com>
parents:
6483
diff
changeset
|
166 | g_return_if_fail(format != NULL); |
|
41d2d86860f3
[gaim-migrate @ 7248]
Christian Hammond <chipx86@chipx86.com>
parents:
6483
diff
changeset
|
167 | |
|
41d2d86860f3
[gaim-migrate @ 7248]
Christian Hammond <chipx86@chipx86.com>
parents:
6483
diff
changeset
|
168 | va_start(args, format); |
| 15884 | 169 | purple_debug_vargs(PURPLE_DEBUG_ERROR, category, format, args); |
|
6721
41d2d86860f3
[gaim-migrate @ 7248]
Christian Hammond <chipx86@chipx86.com>
parents:
6483
diff
changeset
|
170 | va_end(args); |
|
41d2d86860f3
[gaim-migrate @ 7248]
Christian Hammond <chipx86@chipx86.com>
parents:
6483
diff
changeset
|
171 | } |
|
41d2d86860f3
[gaim-migrate @ 7248]
Christian Hammond <chipx86@chipx86.com>
parents:
6483
diff
changeset
|
172 | |
|
41d2d86860f3
[gaim-migrate @ 7248]
Christian Hammond <chipx86@chipx86.com>
parents:
6483
diff
changeset
|
173 | void |
| 15884 | 174 | purple_debug_fatal(const char *category, const char *format, ...) |
|
6721
41d2d86860f3
[gaim-migrate @ 7248]
Christian Hammond <chipx86@chipx86.com>
parents:
6483
diff
changeset
|
175 | { |
|
41d2d86860f3
[gaim-migrate @ 7248]
Christian Hammond <chipx86@chipx86.com>
parents:
6483
diff
changeset
|
176 | va_list args; |
|
41d2d86860f3
[gaim-migrate @ 7248]
Christian Hammond <chipx86@chipx86.com>
parents:
6483
diff
changeset
|
177 | |
|
41d2d86860f3
[gaim-migrate @ 7248]
Christian Hammond <chipx86@chipx86.com>
parents:
6483
diff
changeset
|
178 | g_return_if_fail(format != NULL); |
|
41d2d86860f3
[gaim-migrate @ 7248]
Christian Hammond <chipx86@chipx86.com>
parents:
6483
diff
changeset
|
179 | |
|
41d2d86860f3
[gaim-migrate @ 7248]
Christian Hammond <chipx86@chipx86.com>
parents:
6483
diff
changeset
|
180 | va_start(args, format); |
| 15884 | 181 | purple_debug_vargs(PURPLE_DEBUG_FATAL, category, format, args); |
|
6721
41d2d86860f3
[gaim-migrate @ 7248]
Christian Hammond <chipx86@chipx86.com>
parents:
6483
diff
changeset
|
182 | va_end(args); |
|
41d2d86860f3
[gaim-migrate @ 7248]
Christian Hammond <chipx86@chipx86.com>
parents:
6483
diff
changeset
|
183 | } |
|
41d2d86860f3
[gaim-migrate @ 7248]
Christian Hammond <chipx86@chipx86.com>
parents:
6483
diff
changeset
|
184 | |
|
41d2d86860f3
[gaim-migrate @ 7248]
Christian Hammond <chipx86@chipx86.com>
parents:
6483
diff
changeset
|
185 | void |
| 15884 | 186 | purple_debug_set_enabled(gboolean enabled) |
|
10307
f3ba80364053
[gaim-migrate @ 11497]
Mark Doliner <markdoliner@pidgin.im>
parents:
8046
diff
changeset
|
187 | { |
|
f3ba80364053
[gaim-migrate @ 11497]
Mark Doliner <markdoliner@pidgin.im>
parents:
8046
diff
changeset
|
188 | debug_enabled = enabled; |
|
f3ba80364053
[gaim-migrate @ 11497]
Mark Doliner <markdoliner@pidgin.im>
parents:
8046
diff
changeset
|
189 | } |
|
f3ba80364053
[gaim-migrate @ 11497]
Mark Doliner <markdoliner@pidgin.im>
parents:
8046
diff
changeset
|
190 | |
|
f3ba80364053
[gaim-migrate @ 11497]
Mark Doliner <markdoliner@pidgin.im>
parents:
8046
diff
changeset
|
191 | gboolean |
| 15884 | 192 | purple_debug_is_enabled() |
|
10307
f3ba80364053
[gaim-migrate @ 11497]
Mark Doliner <markdoliner@pidgin.im>
parents:
8046
diff
changeset
|
193 | { |
|
f3ba80364053
[gaim-migrate @ 11497]
Mark Doliner <markdoliner@pidgin.im>
parents:
8046
diff
changeset
|
194 | return debug_enabled; |
|
f3ba80364053
[gaim-migrate @ 11497]
Mark Doliner <markdoliner@pidgin.im>
parents:
8046
diff
changeset
|
195 | } |
|
f3ba80364053
[gaim-migrate @ 11497]
Mark Doliner <markdoliner@pidgin.im>
parents:
8046
diff
changeset
|
196 | |
| 35572 | 197 | static PurpleDebugUiOps * |
| 198 | purple_debug_ui_ops_copy(PurpleDebugUiOps *ops) | |
| 199 | { | |
| 200 | PurpleDebugUiOps *ops_new; | |
| 201 | ||
| 202 | g_return_val_if_fail(ops != NULL, NULL); | |
| 203 | ||
| 204 | ops_new = g_new(PurpleDebugUiOps, 1); | |
| 205 | *ops_new = *ops; | |
| 206 | ||
| 207 | return ops_new; | |
| 208 | } | |
| 209 | ||
| 210 | GType | |
| 211 | purple_debug_ui_ops_get_type(void) | |
| 212 | { | |
| 213 | static GType type = 0; | |
| 214 | ||
| 215 | if (type == 0) { | |
| 216 | type = g_boxed_type_register_static("PurpleDebugUiOps", | |
| 217 | (GBoxedCopyFunc)purple_debug_ui_ops_copy, | |
|
35597
7fcfcf147b99
Use g_free as UiOps structures GBoxed free function
Ankit Vani <a@nevitus.org>
parents:
35572
diff
changeset
|
218 | (GBoxedFreeFunc)g_free); |
| 35572 | 219 | } |
| 220 | ||
| 221 | return type; | |
| 222 | } | |
| 223 | ||
|
10307
f3ba80364053
[gaim-migrate @ 11497]
Mark Doliner <markdoliner@pidgin.im>
parents:
8046
diff
changeset
|
224 | void |
| 15884 | 225 | purple_debug_set_ui_ops(PurpleDebugUiOps *ops) |
| 5212 | 226 | { |
| 227 | debug_ui_ops = ops; | |
| 228 | } | |
| 229 | ||
|
27542
a7acdc4ba23f
Move the handling of PURPLE_UNSAFE_DEBUG to purple_debug_init(). Also add
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
20147
diff
changeset
|
230 | gboolean |
|
a7acdc4ba23f
Move the handling of PURPLE_UNSAFE_DEBUG to purple_debug_init(). Also add
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
20147
diff
changeset
|
231 | purple_debug_is_verbose() |
|
a7acdc4ba23f
Move the handling of PURPLE_UNSAFE_DEBUG to purple_debug_init(). Also add
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
20147
diff
changeset
|
232 | { |
|
a7acdc4ba23f
Move the handling of PURPLE_UNSAFE_DEBUG to purple_debug_init(). Also add
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
20147
diff
changeset
|
233 | return debug_verbose; |
|
a7acdc4ba23f
Move the handling of PURPLE_UNSAFE_DEBUG to purple_debug_init(). Also add
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
20147
diff
changeset
|
234 | } |
|
a7acdc4ba23f
Move the handling of PURPLE_UNSAFE_DEBUG to purple_debug_init(). Also add
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
20147
diff
changeset
|
235 | |
|
a7acdc4ba23f
Move the handling of PURPLE_UNSAFE_DEBUG to purple_debug_init(). Also add
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
20147
diff
changeset
|
236 | void |
|
a7acdc4ba23f
Move the handling of PURPLE_UNSAFE_DEBUG to purple_debug_init(). Also add
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
20147
diff
changeset
|
237 | purple_debug_set_verbose(gboolean verbose) |
|
a7acdc4ba23f
Move the handling of PURPLE_UNSAFE_DEBUG to purple_debug_init(). Also add
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
20147
diff
changeset
|
238 | { |
|
a7acdc4ba23f
Move the handling of PURPLE_UNSAFE_DEBUG to purple_debug_init(). Also add
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
20147
diff
changeset
|
239 | debug_verbose = verbose; |
|
a7acdc4ba23f
Move the handling of PURPLE_UNSAFE_DEBUG to purple_debug_init(). Also add
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
20147
diff
changeset
|
240 | } |
|
a7acdc4ba23f
Move the handling of PURPLE_UNSAFE_DEBUG to purple_debug_init(). Also add
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
20147
diff
changeset
|
241 | |
|
a7acdc4ba23f
Move the handling of PURPLE_UNSAFE_DEBUG to purple_debug_init(). Also add
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
20147
diff
changeset
|
242 | gboolean |
|
a7acdc4ba23f
Move the handling of PURPLE_UNSAFE_DEBUG to purple_debug_init(). Also add
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
20147
diff
changeset
|
243 | purple_debug_is_unsafe() |
|
a7acdc4ba23f
Move the handling of PURPLE_UNSAFE_DEBUG to purple_debug_init(). Also add
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
20147
diff
changeset
|
244 | { |
|
a7acdc4ba23f
Move the handling of PURPLE_UNSAFE_DEBUG to purple_debug_init(). Also add
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
20147
diff
changeset
|
245 | return debug_unsafe; |
|
a7acdc4ba23f
Move the handling of PURPLE_UNSAFE_DEBUG to purple_debug_init(). Also add
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
20147
diff
changeset
|
246 | } |
|
a7acdc4ba23f
Move the handling of PURPLE_UNSAFE_DEBUG to purple_debug_init(). Also add
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
20147
diff
changeset
|
247 | |
|
a7acdc4ba23f
Move the handling of PURPLE_UNSAFE_DEBUG to purple_debug_init(). Also add
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
20147
diff
changeset
|
248 | void |
|
a7acdc4ba23f
Move the handling of PURPLE_UNSAFE_DEBUG to purple_debug_init(). Also add
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
20147
diff
changeset
|
249 | purple_debug_set_unsafe(gboolean unsafe) |
|
a7acdc4ba23f
Move the handling of PURPLE_UNSAFE_DEBUG to purple_debug_init(). Also add
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
20147
diff
changeset
|
250 | { |
|
a7acdc4ba23f
Move the handling of PURPLE_UNSAFE_DEBUG to purple_debug_init(). Also add
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
20147
diff
changeset
|
251 | debug_unsafe = unsafe; |
|
a7acdc4ba23f
Move the handling of PURPLE_UNSAFE_DEBUG to purple_debug_init(). Also add
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
20147
diff
changeset
|
252 | } |
|
a7acdc4ba23f
Move the handling of PURPLE_UNSAFE_DEBUG to purple_debug_init(). Also add
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
20147
diff
changeset
|
253 | |
|
34296
d31a4f3b547e
Debug log: optional colored output and no need for add linefeed at the end of each message
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
32438
diff
changeset
|
254 | void |
|
d31a4f3b547e
Debug log: optional colored output and no need for add linefeed at the end of each message
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
32438
diff
changeset
|
255 | purple_debug_set_colored(gboolean colored) |
|
d31a4f3b547e
Debug log: optional colored output and no need for add linefeed at the end of each message
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
32438
diff
changeset
|
256 | { |
|
d31a4f3b547e
Debug log: optional colored output and no need for add linefeed at the end of each message
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
32438
diff
changeset
|
257 | debug_colored = colored; |
|
d31a4f3b547e
Debug log: optional colored output and no need for add linefeed at the end of each message
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
32438
diff
changeset
|
258 | } |
|
d31a4f3b547e
Debug log: optional colored output and no need for add linefeed at the end of each message
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
32438
diff
changeset
|
259 | |
| 15884 | 260 | PurpleDebugUiOps * |
| 261 | purple_debug_get_ui_ops(void) | |
| 5212 | 262 | { |
| 263 | return debug_ui_ops; | |
| 264 | } | |
|
10307
f3ba80364053
[gaim-migrate @ 11497]
Mark Doliner <markdoliner@pidgin.im>
parents:
8046
diff
changeset
|
265 | |
|
f3ba80364053
[gaim-migrate @ 11497]
Mark Doliner <markdoliner@pidgin.im>
parents:
8046
diff
changeset
|
266 | void |
| 15884 | 267 | purple_debug_init(void) |
|
10307
f3ba80364053
[gaim-migrate @ 11497]
Mark Doliner <markdoliner@pidgin.im>
parents:
8046
diff
changeset
|
268 | { |
|
27542
a7acdc4ba23f
Move the handling of PURPLE_UNSAFE_DEBUG to purple_debug_init(). Also add
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
20147
diff
changeset
|
269 | /* Read environment variables once per init */ |
|
a7acdc4ba23f
Move the handling of PURPLE_UNSAFE_DEBUG to purple_debug_init(). Also add
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
20147
diff
changeset
|
270 | if(g_getenv("PURPLE_UNSAFE_DEBUG")) |
|
a7acdc4ba23f
Move the handling of PURPLE_UNSAFE_DEBUG to purple_debug_init(). Also add
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
20147
diff
changeset
|
271 | purple_debug_set_unsafe(TRUE); |
|
a7acdc4ba23f
Move the handling of PURPLE_UNSAFE_DEBUG to purple_debug_init(). Also add
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
20147
diff
changeset
|
272 | |
|
a7acdc4ba23f
Move the handling of PURPLE_UNSAFE_DEBUG to purple_debug_init(). Also add
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
20147
diff
changeset
|
273 | if(g_getenv("PURPLE_VERBOSE_DEBUG")) |
|
a7acdc4ba23f
Move the handling of PURPLE_UNSAFE_DEBUG to purple_debug_init(). Also add
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
20147
diff
changeset
|
274 | purple_debug_set_verbose(TRUE); |
|
a7acdc4ba23f
Move the handling of PURPLE_UNSAFE_DEBUG to purple_debug_init(). Also add
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
20147
diff
changeset
|
275 | |
|
17318
ce44d0f8095d
Un-break the API so the next release doesn't have to be 3.0.0 :)
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17040
diff
changeset
|
276 | purple_prefs_add_none("/purple/debug"); |
|
10307
f3ba80364053
[gaim-migrate @ 11497]
Mark Doliner <markdoliner@pidgin.im>
parents:
8046
diff
changeset
|
277 | } |
|
27542
a7acdc4ba23f
Move the handling of PURPLE_UNSAFE_DEBUG to purple_debug_init(). Also add
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
20147
diff
changeset
|
278 |