Wed, 02 Oct 2019 06:21:41 -0400
Remove redundant conditions.
|
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 | |
|
38643
cb7fbf08fcb7
Convert PurpleDebugUiOps into an interface.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
35597
diff
changeset
|
26 | static PurpleDebugUi *debug_ui = 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 | { | |
|
38643
cb7fbf08fcb7
Convert PurpleDebugUiOps into an interface.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
35597
diff
changeset
|
54 | PurpleDebugUi *ops; |
|
cb7fbf08fcb7
Convert PurpleDebugUiOps into an interface.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
35597
diff
changeset
|
55 | PurpleDebugUiInterface *iface; |
|
13988
a178d3dcbb7f
[gaim-migrate @ 16445]
Mark Doliner <markdoliner@pidgin.im>
parents:
13105
diff
changeset
|
56 | char *arg_s = NULL; |
| 5212 | 57 | |
| 15884 | 58 | g_return_if_fail(level != PURPLE_DEBUG_ALL); |
| 5212 | 59 | g_return_if_fail(format != NULL); |
| 60 | ||
|
38643
cb7fbf08fcb7
Convert PurpleDebugUiOps into an interface.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
35597
diff
changeset
|
61 | ops = purple_debug_get_ui(); |
|
cb7fbf08fcb7
Convert PurpleDebugUiOps into an interface.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
35597
diff
changeset
|
62 | if (!ops) |
|
cb7fbf08fcb7
Convert PurpleDebugUiOps into an interface.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
35597
diff
changeset
|
63 | return; |
|
cb7fbf08fcb7
Convert PurpleDebugUiOps into an interface.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
35597
diff
changeset
|
64 | iface = PURPLE_DEBUG_UI_GET_IFACE(ops); |
|
cb7fbf08fcb7
Convert PurpleDebugUiOps into an interface.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
35597
diff
changeset
|
65 | if (!iface) |
|
cb7fbf08fcb7
Convert PurpleDebugUiOps into an interface.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
35597
diff
changeset
|
66 | return; |
|
13988
a178d3dcbb7f
[gaim-migrate @ 16445]
Mark Doliner <markdoliner@pidgin.im>
parents:
13105
diff
changeset
|
67 | |
|
39913
ce96d4639dc7
Remove redundant conditions.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38643
diff
changeset
|
68 | if (!debug_enabled && |
|
ce96d4639dc7
Remove redundant conditions.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38643
diff
changeset
|
69 | ((iface->print == NULL) || |
|
ce96d4639dc7
Remove redundant conditions.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38643
diff
changeset
|
70 | (iface->is_enabled && !iface->is_enabled(ops, level, category)))) { |
|
13988
a178d3dcbb7f
[gaim-migrate @ 16445]
Mark Doliner <markdoliner@pidgin.im>
parents:
13105
diff
changeset
|
71 | return; |
|
39913
ce96d4639dc7
Remove redundant conditions.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38643
diff
changeset
|
72 | } |
|
13988
a178d3dcbb7f
[gaim-migrate @ 16445]
Mark Doliner <markdoliner@pidgin.im>
parents:
13105
diff
changeset
|
73 | |
|
a178d3dcbb7f
[gaim-migrate @ 16445]
Mark Doliner <markdoliner@pidgin.im>
parents:
13105
diff
changeset
|
74 | 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
|
75 | g_strchomp(arg_s); /* strip trailing linefeeds */ |
|
13988
a178d3dcbb7f
[gaim-migrate @ 16445]
Mark Doliner <markdoliner@pidgin.im>
parents:
13105
diff
changeset
|
76 | |
|
10307
f3ba80364053
[gaim-migrate @ 11497]
Mark Doliner <markdoliner@pidgin.im>
parents:
8046
diff
changeset
|
77 | if (debug_enabled) { |
|
13988
a178d3dcbb7f
[gaim-migrate @ 16445]
Mark Doliner <markdoliner@pidgin.im>
parents:
13105
diff
changeset
|
78 | 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
|
79 | 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
|
80 | 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
|
81 | const gchar *format_pre, *format_post; |
|
10307
f3ba80364053
[gaim-migrate @ 11497]
Mark Doliner <markdoliner@pidgin.im>
parents:
8046
diff
changeset
|
82 | |
|
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
|
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 | 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
|
85 | |
|
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 | 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
|
87 | 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
|
88 | 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
|
89 | 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
|
90 | 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
|
91 | 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
|
92 | 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
|
93 | 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
|
94 | 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
|
95 | 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
|
96 | 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
|
97 | 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
|
98 | |
|
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
|
99 | 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
|
100 | 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
|
101 | |
|
cb33027a36e4
Force timestamps always on for debug log and debug window. Making this
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16478
diff
changeset
|
102 | 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
|
103 | ts_s = g_strdup_printf("(%s) ", mdate); |
|
10307
f3ba80364053
[gaim-migrate @ 11497]
Mark Doliner <markdoliner@pidgin.im>
parents:
8046
diff
changeset
|
104 | |
|
f3ba80364053
[gaim-migrate @ 11497]
Mark Doliner <markdoliner@pidgin.im>
parents:
8046
diff
changeset
|
105 | 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
|
106 | 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
|
107 | 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
|
108 | 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
|
109 | |
|
f3ba80364053
[gaim-migrate @ 11497]
Mark Doliner <markdoliner@pidgin.im>
parents:
8046
diff
changeset
|
110 | g_free(ts_s); |
|
f3ba80364053
[gaim-migrate @ 11497]
Mark Doliner <markdoliner@pidgin.im>
parents:
8046
diff
changeset
|
111 | } |
|
f3ba80364053
[gaim-migrate @ 11497]
Mark Doliner <markdoliner@pidgin.im>
parents:
8046
diff
changeset
|
112 | |
|
39913
ce96d4639dc7
Remove redundant conditions.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38643
diff
changeset
|
113 | if (iface->print != NULL) { |
|
38643
cb7fbf08fcb7
Convert PurpleDebugUiOps into an interface.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
35597
diff
changeset
|
114 | iface->print(ops, level, category, arg_s); |
|
39913
ce96d4639dc7
Remove redundant conditions.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38643
diff
changeset
|
115 | } |
| 5212 | 116 | |
|
13988
a178d3dcbb7f
[gaim-migrate @ 16445]
Mark Doliner <markdoliner@pidgin.im>
parents:
13105
diff
changeset
|
117 | g_free(arg_s); |
| 5212 | 118 | } |
| 119 | ||
| 120 | void | |
| 15884 | 121 | purple_debug(PurpleDebugLevel level, const char *category, |
| 5212 | 122 | const char *format, ...) |
| 123 | { | |
| 124 | va_list args; | |
| 125 | ||
| 15884 | 126 | g_return_if_fail(level != PURPLE_DEBUG_ALL); |
| 5212 | 127 | g_return_if_fail(format != NULL); |
| 128 | ||
| 129 | va_start(args, format); | |
| 15884 | 130 | purple_debug_vargs(level, category, format, args); |
| 5212 | 131 | va_end(args); |
| 132 | } | |
| 133 | ||
| 134 | void | |
| 15884 | 135 | purple_debug_misc(const char *category, const char *format, ...) |
|
6721
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 | va_list args; |
|
41d2d86860f3
[gaim-migrate @ 7248]
Christian Hammond <chipx86@chipx86.com>
parents:
6483
diff
changeset
|
138 | |
|
41d2d86860f3
[gaim-migrate @ 7248]
Christian Hammond <chipx86@chipx86.com>
parents:
6483
diff
changeset
|
139 | g_return_if_fail(format != NULL); |
|
41d2d86860f3
[gaim-migrate @ 7248]
Christian Hammond <chipx86@chipx86.com>
parents:
6483
diff
changeset
|
140 | |
|
41d2d86860f3
[gaim-migrate @ 7248]
Christian Hammond <chipx86@chipx86.com>
parents:
6483
diff
changeset
|
141 | va_start(args, format); |
| 15884 | 142 | purple_debug_vargs(PURPLE_DEBUG_MISC, category, format, args); |
|
6721
41d2d86860f3
[gaim-migrate @ 7248]
Christian Hammond <chipx86@chipx86.com>
parents:
6483
diff
changeset
|
143 | va_end(args); |
|
41d2d86860f3
[gaim-migrate @ 7248]
Christian Hammond <chipx86@chipx86.com>
parents:
6483
diff
changeset
|
144 | } |
|
41d2d86860f3
[gaim-migrate @ 7248]
Christian Hammond <chipx86@chipx86.com>
parents:
6483
diff
changeset
|
145 | |
|
41d2d86860f3
[gaim-migrate @ 7248]
Christian Hammond <chipx86@chipx86.com>
parents:
6483
diff
changeset
|
146 | void |
| 15884 | 147 | purple_debug_info(const char *category, const char *format, ...) |
|
6721
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 | va_list args; |
|
41d2d86860f3
[gaim-migrate @ 7248]
Christian Hammond <chipx86@chipx86.com>
parents:
6483
diff
changeset
|
150 | |
|
41d2d86860f3
[gaim-migrate @ 7248]
Christian Hammond <chipx86@chipx86.com>
parents:
6483
diff
changeset
|
151 | g_return_if_fail(format != NULL); |
|
41d2d86860f3
[gaim-migrate @ 7248]
Christian Hammond <chipx86@chipx86.com>
parents:
6483
diff
changeset
|
152 | |
|
41d2d86860f3
[gaim-migrate @ 7248]
Christian Hammond <chipx86@chipx86.com>
parents:
6483
diff
changeset
|
153 | va_start(args, format); |
| 15884 | 154 | purple_debug_vargs(PURPLE_DEBUG_INFO, category, format, args); |
|
6721
41d2d86860f3
[gaim-migrate @ 7248]
Christian Hammond <chipx86@chipx86.com>
parents:
6483
diff
changeset
|
155 | va_end(args); |
|
41d2d86860f3
[gaim-migrate @ 7248]
Christian Hammond <chipx86@chipx86.com>
parents:
6483
diff
changeset
|
156 | } |
|
41d2d86860f3
[gaim-migrate @ 7248]
Christian Hammond <chipx86@chipx86.com>
parents:
6483
diff
changeset
|
157 | |
|
41d2d86860f3
[gaim-migrate @ 7248]
Christian Hammond <chipx86@chipx86.com>
parents:
6483
diff
changeset
|
158 | void |
| 15884 | 159 | purple_debug_warning(const char *category, const char *format, ...) |
|
6721
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 | va_list args; |
|
41d2d86860f3
[gaim-migrate @ 7248]
Christian Hammond <chipx86@chipx86.com>
parents:
6483
diff
changeset
|
162 | |
|
41d2d86860f3
[gaim-migrate @ 7248]
Christian Hammond <chipx86@chipx86.com>
parents:
6483
diff
changeset
|
163 | g_return_if_fail(format != NULL); |
|
41d2d86860f3
[gaim-migrate @ 7248]
Christian Hammond <chipx86@chipx86.com>
parents:
6483
diff
changeset
|
164 | |
|
41d2d86860f3
[gaim-migrate @ 7248]
Christian Hammond <chipx86@chipx86.com>
parents:
6483
diff
changeset
|
165 | va_start(args, format); |
| 15884 | 166 | purple_debug_vargs(PURPLE_DEBUG_WARNING, category, format, args); |
|
6721
41d2d86860f3
[gaim-migrate @ 7248]
Christian Hammond <chipx86@chipx86.com>
parents:
6483
diff
changeset
|
167 | va_end(args); |
|
41d2d86860f3
[gaim-migrate @ 7248]
Christian Hammond <chipx86@chipx86.com>
parents:
6483
diff
changeset
|
168 | } |
|
41d2d86860f3
[gaim-migrate @ 7248]
Christian Hammond <chipx86@chipx86.com>
parents:
6483
diff
changeset
|
169 | |
|
41d2d86860f3
[gaim-migrate @ 7248]
Christian Hammond <chipx86@chipx86.com>
parents:
6483
diff
changeset
|
170 | void |
| 15884 | 171 | purple_debug_error(const char *category, const char *format, ...) |
|
6721
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 | va_list args; |
|
41d2d86860f3
[gaim-migrate @ 7248]
Christian Hammond <chipx86@chipx86.com>
parents:
6483
diff
changeset
|
174 | |
|
41d2d86860f3
[gaim-migrate @ 7248]
Christian Hammond <chipx86@chipx86.com>
parents:
6483
diff
changeset
|
175 | g_return_if_fail(format != NULL); |
|
41d2d86860f3
[gaim-migrate @ 7248]
Christian Hammond <chipx86@chipx86.com>
parents:
6483
diff
changeset
|
176 | |
|
41d2d86860f3
[gaim-migrate @ 7248]
Christian Hammond <chipx86@chipx86.com>
parents:
6483
diff
changeset
|
177 | va_start(args, format); |
| 15884 | 178 | purple_debug_vargs(PURPLE_DEBUG_ERROR, category, format, args); |
|
6721
41d2d86860f3
[gaim-migrate @ 7248]
Christian Hammond <chipx86@chipx86.com>
parents:
6483
diff
changeset
|
179 | va_end(args); |
|
41d2d86860f3
[gaim-migrate @ 7248]
Christian Hammond <chipx86@chipx86.com>
parents:
6483
diff
changeset
|
180 | } |
|
41d2d86860f3
[gaim-migrate @ 7248]
Christian Hammond <chipx86@chipx86.com>
parents:
6483
diff
changeset
|
181 | |
|
41d2d86860f3
[gaim-migrate @ 7248]
Christian Hammond <chipx86@chipx86.com>
parents:
6483
diff
changeset
|
182 | void |
| 15884 | 183 | purple_debug_fatal(const char *category, const char *format, ...) |
|
6721
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 | va_list args; |
|
41d2d86860f3
[gaim-migrate @ 7248]
Christian Hammond <chipx86@chipx86.com>
parents:
6483
diff
changeset
|
186 | |
|
41d2d86860f3
[gaim-migrate @ 7248]
Christian Hammond <chipx86@chipx86.com>
parents:
6483
diff
changeset
|
187 | g_return_if_fail(format != NULL); |
|
41d2d86860f3
[gaim-migrate @ 7248]
Christian Hammond <chipx86@chipx86.com>
parents:
6483
diff
changeset
|
188 | |
|
41d2d86860f3
[gaim-migrate @ 7248]
Christian Hammond <chipx86@chipx86.com>
parents:
6483
diff
changeset
|
189 | va_start(args, format); |
| 15884 | 190 | purple_debug_vargs(PURPLE_DEBUG_FATAL, category, format, args); |
|
6721
41d2d86860f3
[gaim-migrate @ 7248]
Christian Hammond <chipx86@chipx86.com>
parents:
6483
diff
changeset
|
191 | va_end(args); |
|
41d2d86860f3
[gaim-migrate @ 7248]
Christian Hammond <chipx86@chipx86.com>
parents:
6483
diff
changeset
|
192 | } |
|
41d2d86860f3
[gaim-migrate @ 7248]
Christian Hammond <chipx86@chipx86.com>
parents:
6483
diff
changeset
|
193 | |
|
41d2d86860f3
[gaim-migrate @ 7248]
Christian Hammond <chipx86@chipx86.com>
parents:
6483
diff
changeset
|
194 | void |
| 15884 | 195 | purple_debug_set_enabled(gboolean enabled) |
|
10307
f3ba80364053
[gaim-migrate @ 11497]
Mark Doliner <markdoliner@pidgin.im>
parents:
8046
diff
changeset
|
196 | { |
|
f3ba80364053
[gaim-migrate @ 11497]
Mark Doliner <markdoliner@pidgin.im>
parents:
8046
diff
changeset
|
197 | debug_enabled = enabled; |
|
f3ba80364053
[gaim-migrate @ 11497]
Mark Doliner <markdoliner@pidgin.im>
parents:
8046
diff
changeset
|
198 | } |
|
f3ba80364053
[gaim-migrate @ 11497]
Mark Doliner <markdoliner@pidgin.im>
parents:
8046
diff
changeset
|
199 | |
|
f3ba80364053
[gaim-migrate @ 11497]
Mark Doliner <markdoliner@pidgin.im>
parents:
8046
diff
changeset
|
200 | gboolean |
| 15884 | 201 | purple_debug_is_enabled() |
|
10307
f3ba80364053
[gaim-migrate @ 11497]
Mark Doliner <markdoliner@pidgin.im>
parents:
8046
diff
changeset
|
202 | { |
|
f3ba80364053
[gaim-migrate @ 11497]
Mark Doliner <markdoliner@pidgin.im>
parents:
8046
diff
changeset
|
203 | return debug_enabled; |
|
f3ba80364053
[gaim-migrate @ 11497]
Mark Doliner <markdoliner@pidgin.im>
parents:
8046
diff
changeset
|
204 | } |
|
f3ba80364053
[gaim-migrate @ 11497]
Mark Doliner <markdoliner@pidgin.im>
parents:
8046
diff
changeset
|
205 | |
|
38643
cb7fbf08fcb7
Convert PurpleDebugUiOps into an interface.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
35597
diff
changeset
|
206 | void |
|
cb7fbf08fcb7
Convert PurpleDebugUiOps into an interface.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
35597
diff
changeset
|
207 | purple_debug_set_ui(PurpleDebugUi *ops) |
| 35572 | 208 | { |
|
38643
cb7fbf08fcb7
Convert PurpleDebugUiOps into an interface.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
35597
diff
changeset
|
209 | g_set_object(&debug_ui, ops); |
| 5212 | 210 | } |
| 211 | ||
|
27542
a7acdc4ba23f
Move the handling of PURPLE_UNSAFE_DEBUG to purple_debug_init(). Also add
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
20147
diff
changeset
|
212 | gboolean |
|
a7acdc4ba23f
Move the handling of PURPLE_UNSAFE_DEBUG to purple_debug_init(). Also add
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
20147
diff
changeset
|
213 | 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
|
214 | { |
|
a7acdc4ba23f
Move the handling of PURPLE_UNSAFE_DEBUG to purple_debug_init(). Also add
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
20147
diff
changeset
|
215 | 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
|
216 | } |
|
a7acdc4ba23f
Move the handling of PURPLE_UNSAFE_DEBUG to purple_debug_init(). Also add
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
20147
diff
changeset
|
217 | |
|
a7acdc4ba23f
Move the handling of PURPLE_UNSAFE_DEBUG to purple_debug_init(). Also add
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
20147
diff
changeset
|
218 | void |
|
a7acdc4ba23f
Move the handling of PURPLE_UNSAFE_DEBUG to purple_debug_init(). Also add
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
20147
diff
changeset
|
219 | 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
|
220 | { |
|
a7acdc4ba23f
Move the handling of PURPLE_UNSAFE_DEBUG to purple_debug_init(). Also add
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
20147
diff
changeset
|
221 | 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
|
222 | } |
|
a7acdc4ba23f
Move the handling of PURPLE_UNSAFE_DEBUG to purple_debug_init(). Also add
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
20147
diff
changeset
|
223 | |
|
a7acdc4ba23f
Move the handling of PURPLE_UNSAFE_DEBUG to purple_debug_init(). Also add
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
20147
diff
changeset
|
224 | gboolean |
|
a7acdc4ba23f
Move the handling of PURPLE_UNSAFE_DEBUG to purple_debug_init(). Also add
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
20147
diff
changeset
|
225 | 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
|
226 | { |
|
a7acdc4ba23f
Move the handling of PURPLE_UNSAFE_DEBUG to purple_debug_init(). Also add
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
20147
diff
changeset
|
227 | 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
|
228 | } |
|
a7acdc4ba23f
Move the handling of PURPLE_UNSAFE_DEBUG to purple_debug_init(). Also add
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
20147
diff
changeset
|
229 | |
|
a7acdc4ba23f
Move the handling of PURPLE_UNSAFE_DEBUG to purple_debug_init(). Also add
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
20147
diff
changeset
|
230 | void |
|
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_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
|
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 | 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
|
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 | |
|
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
|
236 | 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
|
237 | 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
|
238 | { |
|
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
|
239 | 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
|
240 | } |
|
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
|
241 | |
|
38643
cb7fbf08fcb7
Convert PurpleDebugUiOps into an interface.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
35597
diff
changeset
|
242 | PurpleDebugUi * |
|
cb7fbf08fcb7
Convert PurpleDebugUiOps into an interface.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
35597
diff
changeset
|
243 | purple_debug_get_ui(void) |
| 5212 | 244 | { |
|
38643
cb7fbf08fcb7
Convert PurpleDebugUiOps into an interface.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
35597
diff
changeset
|
245 | return debug_ui; |
|
cb7fbf08fcb7
Convert PurpleDebugUiOps into an interface.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
35597
diff
changeset
|
246 | } |
|
cb7fbf08fcb7
Convert PurpleDebugUiOps into an interface.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
35597
diff
changeset
|
247 | |
|
cb7fbf08fcb7
Convert PurpleDebugUiOps into an interface.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
35597
diff
changeset
|
248 | G_DEFINE_INTERFACE(PurpleDebugUi, purple_debug_ui, G_TYPE_OBJECT); |
|
cb7fbf08fcb7
Convert PurpleDebugUiOps into an interface.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
35597
diff
changeset
|
249 | |
|
cb7fbf08fcb7
Convert PurpleDebugUiOps into an interface.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
35597
diff
changeset
|
250 | static void |
|
cb7fbf08fcb7
Convert PurpleDebugUiOps into an interface.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
35597
diff
changeset
|
251 | purple_debug_ui_default_init(PurpleDebugUiInterface *iface) |
|
cb7fbf08fcb7
Convert PurpleDebugUiOps into an interface.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
35597
diff
changeset
|
252 | { |
|
cb7fbf08fcb7
Convert PurpleDebugUiOps into an interface.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
35597
diff
changeset
|
253 | /* add properties and signals to the interface here */ |
| 5212 | 254 | } |
|
10307
f3ba80364053
[gaim-migrate @ 11497]
Mark Doliner <markdoliner@pidgin.im>
parents:
8046
diff
changeset
|
255 | |
|
f3ba80364053
[gaim-migrate @ 11497]
Mark Doliner <markdoliner@pidgin.im>
parents:
8046
diff
changeset
|
256 | void |
| 15884 | 257 | purple_debug_init(void) |
|
10307
f3ba80364053
[gaim-migrate @ 11497]
Mark Doliner <markdoliner@pidgin.im>
parents:
8046
diff
changeset
|
258 | { |
|
27542
a7acdc4ba23f
Move the handling of PURPLE_UNSAFE_DEBUG to purple_debug_init(). Also add
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
20147
diff
changeset
|
259 | /* 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
|
260 | 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
|
261 | 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
|
262 | |
|
a7acdc4ba23f
Move the handling of PURPLE_UNSAFE_DEBUG to purple_debug_init(). Also add
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
20147
diff
changeset
|
263 | 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
|
264 | 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
|
265 | |
|
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
|
266 | purple_prefs_add_none("/purple/debug"); |
|
10307
f3ba80364053
[gaim-migrate @ 11497]
Mark Doliner <markdoliner@pidgin.im>
parents:
8046
diff
changeset
|
267 | } |
|
27542
a7acdc4ba23f
Move the handling of PURPLE_UNSAFE_DEBUG to purple_debug_init(). Also add
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
20147
diff
changeset
|
268 |