merge of 'd03c32ee4bd5625c28af8c8b33920944d499eef6'
[pidgin-git.git] / libpurple / debug.h
blob67dd91ce7b3704c1278fac8752f1f767422ed96e
1 /**
2 * @file debug.h Debug API
3 * @ingroup core
4 */
6 /* purple
8 * Purple is the legal property of its developers, whose names are too numerous
9 * to list here. Please refer to the COPYRIGHT file distributed with this
10 * source distribution.
12 * This program is free software; you can redistribute it and/or modify
13 * it under the terms of the GNU General Public License as published by
14 * the Free Software Foundation; either version 2 of the License, or
15 * (at your option) any later version.
17 * This program is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU General Public License for more details.
22 * You should have received a copy of the GNU General Public License
23 * along with this program; if not, write to the Free Software
24 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA
26 #ifndef _PURPLE_DEBUG_H_
27 #define _PURPLE_DEBUG_H_
29 #include <glib.h>
30 #include <stdarg.h>
32 /**
33 * Debug levels.
35 typedef enum
37 PURPLE_DEBUG_ALL = 0, /**< All debug levels. */
38 PURPLE_DEBUG_MISC, /**< General chatter. */
39 PURPLE_DEBUG_INFO, /**< General operation Information. */
40 PURPLE_DEBUG_WARNING, /**< Warnings. */
41 PURPLE_DEBUG_ERROR, /**< Errors. */
42 PURPLE_DEBUG_FATAL /**< Fatal errors. */
44 } PurpleDebugLevel;
46 /**
47 * Debug UI operations.
49 typedef struct
51 void (*print)(PurpleDebugLevel level, const char *category,
52 const char *arg_s);
53 gboolean (*is_enabled)(PurpleDebugLevel level,
54 const char *category);
56 void (*_purple_reserved1)(void);
57 void (*_purple_reserved2)(void);
58 void (*_purple_reserved3)(void);
59 void (*_purple_reserved4)(void);
60 } PurpleDebugUiOps;
62 #ifdef __cplusplus
63 extern "C" {
64 #endif
66 /**************************************************************************/
67 /** @name Debug API */
68 /**************************************************************************/
69 /**
70 * Outputs debug information.
72 * @param level The debug level.
73 * @param category The category (or @c NULL).
74 * @param format The format string.
76 void purple_debug(PurpleDebugLevel level, const char *category,
77 const char *format, ...) G_GNUC_PRINTF(3, 4);
79 /**
80 * Outputs misc. level debug information.
82 * This is a wrapper for purple_debug(), and uses PURPLE_DEBUG_MISC as
83 * the level.
85 * @param category The category (or @c NULL).
86 * @param format The format string.
88 * @see purple_debug()
90 void purple_debug_misc(const char *category, const char *format, ...) G_GNUC_PRINTF(2, 3);
92 /**
93 * Outputs info level debug information.
95 * This is a wrapper for purple_debug(), and uses PURPLE_DEBUG_INFO as
96 * the level.
98 * @param category The category (or @c NULL).
99 * @param format The format string.
101 * @see purple_debug()
103 void purple_debug_info(const char *category, const char *format, ...) G_GNUC_PRINTF(2, 3);
106 * Outputs warning level debug information.
108 * This is a wrapper for purple_debug(), and uses PURPLE_DEBUG_WARNING as
109 * the level.
111 * @param category The category (or @c NULL).
112 * @param format The format string.
114 * @see purple_debug()
116 void purple_debug_warning(const char *category, const char *format, ...) G_GNUC_PRINTF(2, 3);
119 * Outputs error level debug information.
121 * This is a wrapper for purple_debug(), and uses PURPLE_DEBUG_ERROR as
122 * the level.
124 * @param category The category (or @c NULL).
125 * @param format The format string.
127 * @see purple_debug()
129 void purple_debug_error(const char *category, const char *format, ...) G_GNUC_PRINTF(2, 3);
132 * Outputs fatal error level debug information.
134 * This is a wrapper for purple_debug(), and uses PURPLE_DEBUG_ERROR as
135 * the level.
137 * @param category The category (or @c NULL).
138 * @param format The format string.
140 * @see purple_debug()
142 void purple_debug_fatal(const char *category, const char *format, ...) G_GNUC_PRINTF(2, 3);
145 * Enable or disable printing debug output to the console.
147 * @param enabled TRUE to enable debug output or FALSE to disable it.
149 void purple_debug_set_enabled(gboolean enabled);
152 * Check if console debug output is enabled.
154 * @return TRUE if debugging is enabled, FALSE if it is not.
156 gboolean purple_debug_is_enabled(void);
159 * Enable or disable verbose debugging. This ordinarily should only be called
160 * by #purple_debug_init, but there are cases where this can be useful for
161 * plugins.
163 * @param verbose TRUE to enable verbose debugging or FALSE to disable it.
165 * @since 2.6.0
167 void purple_debug_set_verbose(gboolean verbose);
170 * Check if verbose logging is enabled.
172 * @return TRUE if verbose debugging is enabled, FALSE if it is not.
174 * @since 2.6.0
176 gboolean purple_debug_is_verbose(void);
179 * Enable or disable verbose debugging. This ordinarily should only be called
180 * by #purple_debug_init, but there are cases where this can be useful for
181 * plugins.
183 * @param unsafe TRUE to enable verbose debugging or FALSE to disable it.
185 * @since 2.6.0
187 void purple_debug_set_unsafe(gboolean unsafe);
190 * Check if unsafe debugging is enabled.
192 * @return TRUE if verbose debugging is enabled, FALSE if it is not.
194 * @since 2.6.0
196 gboolean purple_debug_is_unsafe(void);
198 /*@}*/
200 /**************************************************************************/
201 /** @name UI Registration Functions */
202 /**************************************************************************/
203 /*@{*/
206 * Sets the UI operations structure to be used when outputting debug
207 * information.
209 * @param ops The UI operations structure.
211 void purple_debug_set_ui_ops(PurpleDebugUiOps *ops);
214 * Returns the UI operations structure used when outputting debug
215 * information.
217 * @return The UI operations structure in use.
219 PurpleDebugUiOps *purple_debug_get_ui_ops(void);
221 /*@}*/
223 /**************************************************************************/
224 /** @name Debug Subsystem */
225 /**************************************************************************/
226 /*@{*/
229 * Initializes the debug subsystem.
231 void purple_debug_init(void);
233 /*@}*/
235 #ifdef __cplusplus
237 #endif
239 #endif /* _PURPLE_DEBUG_H_ */