1 | /* GStreamer |
---|
2 | * Copyright (C) 1999,2000 Erik Walthinsen <omega@cse.ogi.edu> |
---|
3 | * 2000 Wim Taymans <wtay@chello.be> |
---|
4 | * 2003 Benjamin Otte <in7y118@public.uni-hamburg.de> |
---|
5 | * |
---|
6 | * gstinfo.h: debugging functions |
---|
7 | * |
---|
8 | * This library is free software; you can redistribute it and/or |
---|
9 | * modify it under the terms of the GNU Library General Public |
---|
10 | * License as published by the Free Software Foundation; either |
---|
11 | * version 2 of the License, or (at your option) any later version. |
---|
12 | * |
---|
13 | * This library is distributed in the hope that it will be useful, |
---|
14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
---|
16 | * Library General Public License for more details. |
---|
17 | * |
---|
18 | * You should have received a copy of the GNU Library General Public |
---|
19 | * License along with this library; if not, write to the |
---|
20 | * Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
---|
21 | * Boston, MA 02111-1307, USA. |
---|
22 | */ |
---|
23 | |
---|
24 | #ifndef __GSTINFO_H__ |
---|
25 | #define __GSTINFO_H__ |
---|
26 | |
---|
27 | #include <glib.h> |
---|
28 | #include <glib-object.h> |
---|
29 | #include <gst/gstatomic.h> |
---|
30 | #include <gst/gstconfig.h> |
---|
31 | |
---|
32 | G_BEGIN_DECLS |
---|
33 | |
---|
34 | /* |
---|
35 | * GStreamer's debugging subsystem is an easy way to get information about what |
---|
36 | * the application is doing. |
---|
37 | * It is not meant for programming errors. Use GLibs methods (g_warning and so |
---|
38 | * on for that. |
---|
39 | */ |
---|
40 | |
---|
41 | /* log levels */ |
---|
42 | typedef enum { |
---|
43 | GST_LEVEL_NONE = 0, |
---|
44 | GST_LEVEL_ERROR, |
---|
45 | GST_LEVEL_WARNING, |
---|
46 | GST_LEVEL_INFO, |
---|
47 | GST_LEVEL_DEBUG, |
---|
48 | GST_LEVEL_LOG, |
---|
49 | /* add more */ |
---|
50 | GST_LEVEL_COUNT |
---|
51 | } GstDebugLevel; |
---|
52 | |
---|
53 | /* we can now override this to be more general in maintainer builds |
---|
54 | * or cvs checkouts */ |
---|
55 | #ifndef GST_LEVEL_DEFAULT |
---|
56 | #define GST_LEVEL_DEFAULT GST_LEVEL_NONE |
---|
57 | #endif |
---|
58 | |
---|
59 | /* defines for format (colors etc) |
---|
60 | * don't change them around, it uses terminal layout |
---|
61 | * Terminal color strings: |
---|
62 | * 00=none 01=bold 04=underscore 05=blink 07=reverse 08=concealed |
---|
63 | * Text color codes: |
---|
64 | * 30=black 31=red 32=green 33=yellow 34=blue 35=magenta 36=cyan 37=white |
---|
65 | * Background color codes: |
---|
66 | * 40=black 41=red 42=green 43=yellow 44=blue 45=magenta 46=cyan 47=white |
---|
67 | */ |
---|
68 | typedef enum { |
---|
69 | /* colors */ |
---|
70 | GST_DEBUG_FG_BLACK = 0x0000, |
---|
71 | GST_DEBUG_FG_RED = 0x0001, |
---|
72 | GST_DEBUG_FG_GREEN = 0x0002, |
---|
73 | GST_DEBUG_FG_YELLOW = 0x0003, |
---|
74 | GST_DEBUG_FG_BLUE = 0x0004, |
---|
75 | GST_DEBUG_FG_MAGENTA = 0x0005, |
---|
76 | GST_DEBUG_FG_CYAN = 0x0006, |
---|
77 | GST_DEBUG_FG_WHITE = 0x0007, |
---|
78 | /* background colors */ |
---|
79 | GST_DEBUG_BG_BLACK = 0x0000, |
---|
80 | GST_DEBUG_BG_RED = 0x0010, |
---|
81 | GST_DEBUG_BG_GREEN = 0x0020, |
---|
82 | GST_DEBUG_BG_YELLOW = 0x0030, |
---|
83 | GST_DEBUG_BG_BLUE = 0x0040, |
---|
84 | GST_DEBUG_BG_MAGENTA = 0x0050, |
---|
85 | GST_DEBUG_BG_CYAN = 0x0060, |
---|
86 | GST_DEBUG_BG_WHITE = 0x0070, |
---|
87 | /* other formats */ |
---|
88 | GST_DEBUG_BOLD = 0x0100, |
---|
89 | GST_DEBUG_UNDERLINE = 0x0200 |
---|
90 | } GstDebugColorFlags; |
---|
91 | |
---|
92 | #define GST_DEBUG_FG_MASK (0x000F) |
---|
93 | #define GST_DEBUG_BG_MASK (0x00F0) |
---|
94 | #define GST_DEBUG_FORMAT_MASK (0xFF00) |
---|
95 | |
---|
96 | typedef struct _GstDebugCategory GstDebugCategory; |
---|
97 | struct _GstDebugCategory { |
---|
98 | /*< private >*/ |
---|
99 | GstAtomicInt * threshold; |
---|
100 | guint color; /* see defines above */ |
---|
101 | |
---|
102 | const gchar * name; |
---|
103 | const gchar * description; |
---|
104 | }; |
---|
105 | |
---|
106 | /********** some convenience macros for debugging **********/ |
---|
107 | |
---|
108 | /* This is needed in printf's if a char* might be NULL. Solaris crashes then. */ |
---|
109 | #define GST_STR_NULL(str) ((str) ? (str) : "(NULL)") |
---|
110 | |
---|
111 | /* easier debugging for pad names */ |
---|
112 | #define GST_DEBUG_PAD_NAME(pad) \ |
---|
113 | (GST_OBJECT_PARENT(pad) != NULL) ? \ |
---|
114 | GST_STR_NULL (GST_OBJECT_NAME (GST_OBJECT_PARENT(pad))) : \ |
---|
115 | "''", GST_OBJECT_NAME (pad) |
---|
116 | |
---|
117 | /* You might want to define GST_FUNCTION in apps' configure script. */ |
---|
118 | #ifndef GST_FUNCTION |
---|
119 | #if defined (__GNUC__) |
---|
120 | # define GST_FUNCTION ((const char*) (__PRETTY_FUNCTION__)) |
---|
121 | #elif defined (G_HAVE_ISO_VARARGS) |
---|
122 | # define GST_FUNCTION ((const char*) (__func__)) |
---|
123 | #else |
---|
124 | # define GST_FUNCTION ((const char*) ("???")) |
---|
125 | #endif |
---|
126 | #endif /* ifndef GST_FUNCTION */ |
---|
127 | |
---|
128 | |
---|
129 | typedef struct _GstDebugMessage GstDebugMessage; |
---|
130 | typedef void (*GstLogFunction) (GstDebugCategory * category, |
---|
131 | GstDebugLevel level, |
---|
132 | const gchar * file, |
---|
133 | const gchar * function, |
---|
134 | gint line, |
---|
135 | GObject * object, |
---|
136 | GstDebugMessage * message, |
---|
137 | gpointer data); |
---|
138 | |
---|
139 | #ifndef GST_DISABLE_GST_DEBUG |
---|
140 | |
---|
141 | void _gst_debug_init (void); |
---|
142 | |
---|
143 | /* note we can't use G_GNUC_PRINTF (7, 8) because gcc chokes on %P, which |
---|
144 | * we use for GST_PTR_FORMAT. */ |
---|
145 | void gst_debug_log (GstDebugCategory * category, |
---|
146 | GstDebugLevel level, |
---|
147 | const gchar * file, |
---|
148 | const gchar * function, |
---|
149 | gint line, |
---|
150 | GObject * object, |
---|
151 | const gchar * format, |
---|
152 | ...) G_GNUC_NO_INSTRUMENT; |
---|
153 | void gst_debug_log_valist (GstDebugCategory * category, |
---|
154 | GstDebugLevel level, |
---|
155 | const gchar * file, |
---|
156 | const gchar * function, |
---|
157 | gint line, |
---|
158 | GObject * object, |
---|
159 | const gchar * format, |
---|
160 | va_list args) G_GNUC_NO_INSTRUMENT; |
---|
161 | |
---|
162 | const gchar * gst_debug_message_get (GstDebugMessage * message); |
---|
163 | |
---|
164 | void gst_debug_log_default (GstDebugCategory * category, |
---|
165 | GstDebugLevel level, |
---|
166 | const gchar * file, |
---|
167 | const gchar * function, |
---|
168 | gint line, |
---|
169 | GObject * object, |
---|
170 | GstDebugMessage * message, |
---|
171 | gpointer unused) G_GNUC_NO_INSTRUMENT; |
---|
172 | |
---|
173 | G_CONST_RETURN gchar * |
---|
174 | gst_debug_level_get_name (GstDebugLevel level); |
---|
175 | |
---|
176 | void gst_debug_add_log_function (GstLogFunction func, |
---|
177 | gpointer data); |
---|
178 | guint gst_debug_remove_log_function (GstLogFunction func); |
---|
179 | guint gst_debug_remove_log_function_by_data (gpointer data); |
---|
180 | |
---|
181 | void gst_debug_set_active (gboolean active); |
---|
182 | gboolean gst_debug_is_active (void); |
---|
183 | |
---|
184 | void gst_debug_set_colored (gboolean colored); |
---|
185 | gboolean gst_debug_is_colored (void); |
---|
186 | |
---|
187 | void gst_debug_set_default_threshold (GstDebugLevel level); |
---|
188 | GstDebugLevel gst_debug_get_default_threshold (void); |
---|
189 | void gst_debug_set_threshold_for_name (const gchar * name, |
---|
190 | GstDebugLevel level); |
---|
191 | void gst_debug_unset_threshold_for_name (const gchar * name); |
---|
192 | |
---|
193 | /** |
---|
194 | * GST_DEBUG_CATEGORY: |
---|
195 | * @cat: the category |
---|
196 | * |
---|
197 | * Defines a GstDebugCategory variable. |
---|
198 | * This macro expands to nothing if debugging is disabled. |
---|
199 | */ |
---|
200 | #define GST_DEBUG_CATEGORY(cat) GstDebugCategory *cat = NULL |
---|
201 | /** |
---|
202 | * GST_DEBUG_CATEGORY_EXTERN: |
---|
203 | * @cat: the category |
---|
204 | * |
---|
205 | * Declares a GstDebugCategory variable as extern. Use in header files. |
---|
206 | * This macro expands to nothing if debugging is disabled. |
---|
207 | */ |
---|
208 | #define GST_DEBUG_CATEGORY_EXTERN(cat) extern GstDebugCategory *cat |
---|
209 | /** |
---|
210 | * GST_DEBUG_CATEGORY_STATIC: |
---|
211 | * @cat: the category |
---|
212 | * |
---|
213 | * Defines a static GstDebugCategory variable. |
---|
214 | * This macro expands to nothing if debugging is disabled. |
---|
215 | */ |
---|
216 | #define GST_DEBUG_CATEGORY_STATIC(cat) static GstDebugCategory *cat = NULL |
---|
217 | /* do not use this function, use the macros below */ |
---|
218 | GstDebugCategory *_gst_debug_category_new (gchar * name, |
---|
219 | guint color, |
---|
220 | gchar * description); |
---|
221 | /** |
---|
222 | * GST_DEBUG_CATEGORY_INIT: |
---|
223 | * @cat: the category to initialize. |
---|
224 | * @name: the name of the category. |
---|
225 | * @color: the colors to use for a color representation or 0 for no color. |
---|
226 | * @description: optional description of the category. |
---|
227 | * |
---|
228 | * Initializes a new #GstDebugCategory with the given properties and set to |
---|
229 | * the default threshold. |
---|
230 | * |
---|
231 | * <note> |
---|
232 | * <para> |
---|
233 | * This macro expands to nothing if debugging is disabled. |
---|
234 | * </para> |
---|
235 | * <para> |
---|
236 | * When naming your category, please follow the following conventions to ensure |
---|
237 | * that the pattern matching for categories works as expected. It is not |
---|
238 | * earth-shattering if you don't follow these conventions, but it would be nice |
---|
239 | * for everyone. |
---|
240 | * </para> |
---|
241 | * <para> |
---|
242 | * If you define a category for a plugin or a feature of it, name the category |
---|
243 | * like the feature. So if you wanted to write a "filesrc" element, you would |
---|
244 | * name the category "filesrc". Use lowercase letters only. |
---|
245 | * If you define more than one category for the same element, append an |
---|
246 | * underscore and an identifier to your categories, like this: "filesrc_cache" |
---|
247 | * </para> |
---|
248 | * <para> |
---|
249 | * If you create a library or an application using debugging categories, use a |
---|
250 | * common prefix followed by an underscore for all your categories. GStreamer |
---|
251 | * uses the GST prefix so GStreamer categories look like "GST_STATES". Be sure |
---|
252 | * to include uppercase letters. |
---|
253 | * </para> |
---|
254 | * </note> |
---|
255 | */ |
---|
256 | #define GST_DEBUG_CATEGORY_INIT(cat,name,color,description) G_STMT_START{\ |
---|
257 | if (cat == NULL) \ |
---|
258 | cat = _gst_debug_category_new (name,color,description); \ |
---|
259 | }G_STMT_END |
---|
260 | |
---|
261 | void gst_debug_category_free (GstDebugCategory * category); |
---|
262 | void gst_debug_category_set_threshold (GstDebugCategory * category, |
---|
263 | GstDebugLevel level); |
---|
264 | void gst_debug_category_reset_threshold(GstDebugCategory * category); |
---|
265 | GstDebugLevel |
---|
266 | gst_debug_category_get_threshold (GstDebugCategory * category); |
---|
267 | G_CONST_RETURN gchar * |
---|
268 | gst_debug_category_get_name (GstDebugCategory * category); |
---|
269 | guint gst_debug_category_get_color (GstDebugCategory * category); |
---|
270 | G_CONST_RETURN gchar * |
---|
271 | gst_debug_category_get_description (GstDebugCategory * category); |
---|
272 | GSList * |
---|
273 | gst_debug_get_all_categories (void); |
---|
274 | |
---|
275 | gchar * gst_debug_construct_term_color (guint colorinfo); |
---|
276 | |
---|
277 | |
---|
278 | GST_EXPORT GstDebugCategory * GST_CAT_DEFAULT; |
---|
279 | /* this symbol may not be used */ |
---|
280 | extern gboolean __gst_debug_enabled; |
---|
281 | |
---|
282 | #ifdef G_HAVE_ISO_VARARGS |
---|
283 | #define GST_CAT_LEVEL_LOG(cat,level,object,...) G_STMT_START{ \ |
---|
284 | if (__gst_debug_enabled) { \ |
---|
285 | gst_debug_log ((cat), (level), __FILE__, GST_FUNCTION, __LINE__, \ |
---|
286 | (GObject *) (object), __VA_ARGS__); \ |
---|
287 | } \ |
---|
288 | }G_STMT_END |
---|
289 | #else /* G_HAVE_GNUC_VARARGS */ |
---|
290 | #ifdef G_HAVE_GNUC_VARARGS |
---|
291 | #define GST_CAT_LEVEL_LOG(cat,level,object,args...) G_STMT_START{ \ |
---|
292 | if (__gst_debug_enabled) { \ |
---|
293 | gst_debug_log ((cat), (level), __FILE__, GST_FUNCTION, __LINE__, \ |
---|
294 | (GObject *) (object), ##args ); \ |
---|
295 | } \ |
---|
296 | }G_STMT_END |
---|
297 | #else /* no variadic macros, use inline */ |
---|
298 | static inline void |
---|
299 | GST_CAT_LEVEL_LOG_valist (GstDebugCategory * cat, |
---|
300 | GstDebugLevel level, gpointer object, const char *format, va_list varargs) |
---|
301 | { |
---|
302 | gst_debug_log_valist (cat, level, "", "", 0, (GObject *) object, format, |
---|
303 | varargs); |
---|
304 | } |
---|
305 | |
---|
306 | static inline void |
---|
307 | GST_CAT_LEVEL_LOG (GstDebugCategory * cat, GstDebugLevel level, |
---|
308 | gpointer object, const char *format, ...) |
---|
309 | { |
---|
310 | if (__gst_debug_enabled) { |
---|
311 | va_list varargs; |
---|
312 | |
---|
313 | va_start (varargs, format); |
---|
314 | GST_CAT_LEVEL_LOG_valist (cat, level, object, format, varargs); |
---|
315 | va_end (varargs); |
---|
316 | } |
---|
317 | } |
---|
318 | #endif |
---|
319 | #endif /* G_HAVE_ISO_VARARGS */ |
---|
320 | |
---|
321 | #ifdef G_HAVE_ISO_VARARGS |
---|
322 | |
---|
323 | #define GST_CAT_ERROR_OBJECT(cat,obj,...) GST_CAT_LEVEL_LOG (cat, GST_LEVEL_ERROR, obj, __VA_ARGS__) |
---|
324 | #define GST_CAT_WARNING_OBJECT(cat,obj,...) GST_CAT_LEVEL_LOG (cat, GST_LEVEL_WARNING, obj, __VA_ARGS__) |
---|
325 | #define GST_CAT_INFO_OBJECT(cat,obj,...) GST_CAT_LEVEL_LOG (cat, GST_LEVEL_INFO, obj, __VA_ARGS__) |
---|
326 | #define GST_CAT_DEBUG_OBJECT(cat,obj,...) GST_CAT_LEVEL_LOG (cat, GST_LEVEL_DEBUG, obj, __VA_ARGS__) |
---|
327 | #define GST_CAT_LOG_OBJECT(cat,obj,...) GST_CAT_LEVEL_LOG (cat, GST_LEVEL_LOG, obj, __VA_ARGS__) |
---|
328 | |
---|
329 | #define GST_CAT_ERROR(cat,...) GST_CAT_LEVEL_LOG (cat, GST_LEVEL_ERROR, NULL, __VA_ARGS__) |
---|
330 | #define GST_CAT_WARNING(cat,...) GST_CAT_LEVEL_LOG (cat, GST_LEVEL_WARNING, NULL, __VA_ARGS__) |
---|
331 | #define GST_CAT_INFO(cat,...) GST_CAT_LEVEL_LOG (cat, GST_LEVEL_INFO, NULL, __VA_ARGS__) |
---|
332 | #define GST_CAT_DEBUG(cat,...) GST_CAT_LEVEL_LOG (cat, GST_LEVEL_DEBUG, NULL, __VA_ARGS__) |
---|
333 | #define GST_CAT_LOG(cat,...) GST_CAT_LEVEL_LOG (cat, GST_LEVEL_LOG, NULL, __VA_ARGS__) |
---|
334 | |
---|
335 | #define GST_ERROR_OBJECT(obj,...) GST_CAT_LEVEL_LOG (GST_CAT_DEFAULT, GST_LEVEL_ERROR, obj, __VA_ARGS__) |
---|
336 | #define GST_WARNING_OBJECT(obj,...) GST_CAT_LEVEL_LOG (GST_CAT_DEFAULT, GST_LEVEL_WARNING, obj, __VA_ARGS__) |
---|
337 | #define GST_INFO_OBJECT(obj,...) GST_CAT_LEVEL_LOG (GST_CAT_DEFAULT, GST_LEVEL_INFO, obj, __VA_ARGS__) |
---|
338 | #define GST_DEBUG_OBJECT(obj,...) GST_CAT_LEVEL_LOG (GST_CAT_DEFAULT, GST_LEVEL_DEBUG, obj, __VA_ARGS__) |
---|
339 | #define GST_LOG_OBJECT(obj,...) GST_CAT_LEVEL_LOG (GST_CAT_DEFAULT, GST_LEVEL_LOG, obj, __VA_ARGS__) |
---|
340 | |
---|
341 | #define GST_ERROR(...) GST_CAT_LEVEL_LOG (GST_CAT_DEFAULT, GST_LEVEL_ERROR, NULL, __VA_ARGS__) |
---|
342 | #define GST_WARNING(...) GST_CAT_LEVEL_LOG (GST_CAT_DEFAULT, GST_LEVEL_WARNING, NULL, __VA_ARGS__) |
---|
343 | #define GST_INFO(...) GST_CAT_LEVEL_LOG (GST_CAT_DEFAULT, GST_LEVEL_INFO, NULL, __VA_ARGS__) |
---|
344 | #define GST_DEBUG(...) GST_CAT_LEVEL_LOG (GST_CAT_DEFAULT, GST_LEVEL_DEBUG, NULL, __VA_ARGS__) |
---|
345 | #define GST_LOG(...) GST_CAT_LEVEL_LOG (GST_CAT_DEFAULT, GST_LEVEL_LOG, NULL, __VA_ARGS__) |
---|
346 | |
---|
347 | #else |
---|
348 | #ifdef G_HAVE_GNUC_VARARGS |
---|
349 | |
---|
350 | #define GST_CAT_ERROR_OBJECT(cat,obj,args...) GST_CAT_LEVEL_LOG (cat, GST_LEVEL_ERROR, obj, ##args ) |
---|
351 | #define GST_CAT_WARNING_OBJECT(cat,obj,args...) GST_CAT_LEVEL_LOG (cat, GST_LEVEL_WARNING, obj, ##args ) |
---|
352 | #define GST_CAT_INFO_OBJECT(cat,obj,args...) GST_CAT_LEVEL_LOG (cat, GST_LEVEL_INFO, obj, ##args ) |
---|
353 | #define GST_CAT_DEBUG_OBJECT(cat,obj,args...) GST_CAT_LEVEL_LOG (cat, GST_LEVEL_DEBUG, obj, ##args ) |
---|
354 | #define GST_CAT_LOG_OBJECT(cat,obj,args...) GST_CAT_LEVEL_LOG (cat, GST_LEVEL_LOG, obj, ##args ) |
---|
355 | |
---|
356 | #define GST_CAT_ERROR(cat,args...) GST_CAT_LEVEL_LOG (cat, GST_LEVEL_ERROR, NULL, ##args ) |
---|
357 | #define GST_CAT_WARNING(cat,args...) GST_CAT_LEVEL_LOG (cat, GST_LEVEL_WARNING, NULL, ##args ) |
---|
358 | #define GST_CAT_INFO(cat,args...) GST_CAT_LEVEL_LOG (cat, GST_LEVEL_INFO, NULL, ##args ) |
---|
359 | #define GST_CAT_DEBUG(cat,args...) GST_CAT_LEVEL_LOG (cat, GST_LEVEL_DEBUG, NULL, ##args ) |
---|
360 | #define GST_CAT_LOG(cat,args...) GST_CAT_LEVEL_LOG (cat, GST_LEVEL_LOG, NULL, ##args ) |
---|
361 | |
---|
362 | #define GST_ERROR_OBJECT(obj,args...) GST_CAT_LEVEL_LOG (GST_CAT_DEFAULT, GST_LEVEL_ERROR, obj, ##args ) |
---|
363 | #define GST_WARNING_OBJECT(obj,args...) GST_CAT_LEVEL_LOG (GST_CAT_DEFAULT, GST_LEVEL_WARNING, obj, ##args ) |
---|
364 | #define GST_INFO_OBJECT(obj,args...) GST_CAT_LEVEL_LOG (GST_CAT_DEFAULT, GST_LEVEL_INFO, obj, ##args ) |
---|
365 | #define GST_DEBUG_OBJECT(obj,args...) GST_CAT_LEVEL_LOG (GST_CAT_DEFAULT, GST_LEVEL_DEBUG, obj, ##args ) |
---|
366 | #define GST_LOG_OBJECT(obj,args...) GST_CAT_LEVEL_LOG (GST_CAT_DEFAULT, GST_LEVEL_LOG, obj, ##args ) |
---|
367 | |
---|
368 | #define GST_ERROR(args...) GST_CAT_LEVEL_LOG (GST_CAT_DEFAULT, GST_LEVEL_ERROR, NULL, ##args ) |
---|
369 | #define GST_WARNING(args...) GST_CAT_LEVEL_LOG (GST_CAT_DEFAULT, GST_LEVEL_WARNING, NULL, ##args ) |
---|
370 | #define GST_INFO(args...) GST_CAT_LEVEL_LOG (GST_CAT_DEFAULT, GST_LEVEL_INFO, NULL, ##args ) |
---|
371 | #define GST_DEBUG(args...) GST_CAT_LEVEL_LOG (GST_CAT_DEFAULT, GST_LEVEL_DEBUG, NULL, ##args ) |
---|
372 | #define GST_LOG(args...) GST_CAT_LEVEL_LOG (GST_CAT_DEFAULT, GST_LEVEL_LOG, NULL, ##args ) |
---|
373 | |
---|
374 | #else |
---|
375 | /* no variadic macros, use inline */ |
---|
376 | static inline void |
---|
377 | GST_CAT_ERROR_OBJECT (GstDebugCategory * cat, gpointer obj, const char *format, |
---|
378 | ...) |
---|
379 | { |
---|
380 | va_list varargs; |
---|
381 | |
---|
382 | va_start (varargs, format); |
---|
383 | GST_CAT_LEVEL_LOG_valist (cat, GST_LEVEL_ERROR, obj, format, varargs); |
---|
384 | va_end (varargs); |
---|
385 | } |
---|
386 | |
---|
387 | static inline void |
---|
388 | GST_CAT_WARNING_OBJECT (GstDebugCategory * cat, gpointer obj, |
---|
389 | const char *format, ...) |
---|
390 | { |
---|
391 | va_list varargs; |
---|
392 | |
---|
393 | va_start (varargs, format); |
---|
394 | GST_CAT_LEVEL_LOG_valist (cat, GST_LEVEL_WARNING, obj, format, varargs); |
---|
395 | va_end (varargs); |
---|
396 | } |
---|
397 | |
---|
398 | static inline void |
---|
399 | GST_CAT_INFO_OBJECT (GstDebugCategory * cat, gpointer obj, const char *format, |
---|
400 | ...) |
---|
401 | { |
---|
402 | va_list varargs; |
---|
403 | |
---|
404 | va_start (varargs, format); |
---|
405 | GST_CAT_LEVEL_LOG_valist (cat, GST_LEVEL_INFO, obj, format, varargs); |
---|
406 | va_end (varargs); |
---|
407 | } |
---|
408 | |
---|
409 | static inline void |
---|
410 | GST_CAT_DEBUG_OBJECT (GstDebugCategory * cat, gpointer obj, const char *format, |
---|
411 | ...) |
---|
412 | { |
---|
413 | va_list varargs; |
---|
414 | |
---|
415 | va_start (varargs, format); |
---|
416 | GST_CAT_LEVEL_LOG_valist (cat, GST_LEVEL_DEBUG, obj, format, varargs); |
---|
417 | va_end (varargs); |
---|
418 | } |
---|
419 | |
---|
420 | static inline void |
---|
421 | GST_CAT_LOG_OBJECT (GstDebugCategory * cat, gpointer obj, const char *format, |
---|
422 | ...) |
---|
423 | { |
---|
424 | va_list varargs; |
---|
425 | |
---|
426 | va_start (varargs, format); |
---|
427 | GST_CAT_LEVEL_LOG_valist (cat, GST_LEVEL_LOG, obj, format, varargs); |
---|
428 | va_end (varargs); |
---|
429 | } |
---|
430 | |
---|
431 | static inline void |
---|
432 | GST_CAT_ERROR (GstDebugCategory * cat, const char *format, ...) |
---|
433 | { |
---|
434 | va_list varargs; |
---|
435 | |
---|
436 | va_start (varargs, format); |
---|
437 | GST_CAT_LEVEL_LOG_valist (cat, GST_LEVEL_ERROR, NULL, format, varargs); |
---|
438 | va_end (varargs); |
---|
439 | } |
---|
440 | |
---|
441 | static inline void |
---|
442 | GST_CAT_WARNING (GstDebugCategory * cat, const char *format, ...) |
---|
443 | { |
---|
444 | va_list varargs; |
---|
445 | |
---|
446 | va_start (varargs, format); |
---|
447 | GST_CAT_LEVEL_LOG_valist (cat, GST_LEVEL_WARNING, NULL, format, varargs); |
---|
448 | va_end (varargs); |
---|
449 | } |
---|
450 | |
---|
451 | static inline void |
---|
452 | GST_CAT_INFO (GstDebugCategory * cat, const char *format, ...) |
---|
453 | { |
---|
454 | va_list varargs; |
---|
455 | |
---|
456 | va_start (varargs, format); |
---|
457 | GST_CAT_LEVEL_LOG_valist (cat, GST_LEVEL_INFO, NULL, format, varargs); |
---|
458 | va_end (varargs); |
---|
459 | } |
---|
460 | |
---|
461 | static inline void |
---|
462 | GST_CAT_DEBUG (GstDebugCategory * cat, const char *format, ...) |
---|
463 | { |
---|
464 | va_list varargs; |
---|
465 | |
---|
466 | va_start (varargs, format); |
---|
467 | GST_CAT_LEVEL_LOG_valist (cat, GST_LEVEL_DEBUG, NULL, format, varargs); |
---|
468 | va_end (varargs); |
---|
469 | } |
---|
470 | |
---|
471 | static inline void |
---|
472 | GST_CAT_LOG (GstDebugCategory * cat, const char *format, ...) |
---|
473 | { |
---|
474 | va_list varargs; |
---|
475 | |
---|
476 | va_start (varargs, format); |
---|
477 | GST_CAT_LEVEL_LOG_valist (cat, GST_LEVEL_LOG, NULL, format, varargs); |
---|
478 | va_end (varargs); |
---|
479 | } |
---|
480 | |
---|
481 | static inline void |
---|
482 | GST_ERROR_OBJECT (gpointer obj, const char *format, ...) |
---|
483 | { |
---|
484 | va_list varargs; |
---|
485 | |
---|
486 | va_start (varargs, format); |
---|
487 | GST_CAT_LEVEL_LOG_valist (GST_CAT_DEFAULT, GST_LEVEL_ERROR, obj, format, |
---|
488 | varargs); |
---|
489 | va_end (varargs); |
---|
490 | } |
---|
491 | |
---|
492 | static inline void |
---|
493 | GST_WARNING_OBJECT (gpointer obj, const char *format, ...) |
---|
494 | { |
---|
495 | va_list varargs; |
---|
496 | |
---|
497 | va_start (varargs, format); |
---|
498 | GST_CAT_LEVEL_LOG_valist (GST_CAT_DEFAULT, GST_LEVEL_WARNING, obj, format, |
---|
499 | varargs); |
---|
500 | va_end (varargs); |
---|
501 | } |
---|
502 | |
---|
503 | static inline void |
---|
504 | GST_INFO_OBJECT (gpointer obj, const char *format, ...) |
---|
505 | { |
---|
506 | va_list varargs; |
---|
507 | |
---|
508 | va_start (varargs, format); |
---|
509 | GST_CAT_LEVEL_LOG_valist (GST_CAT_DEFAULT, GST_LEVEL_INFO, obj, format, |
---|
510 | varargs); |
---|
511 | va_end (varargs); |
---|
512 | } |
---|
513 | |
---|
514 | static inline void |
---|
515 | GST_DEBUG_OBJECT (gpointer obj, const char *format, ...) |
---|
516 | { |
---|
517 | va_list varargs; |
---|
518 | |
---|
519 | va_start (varargs, format); |
---|
520 | GST_CAT_LEVEL_LOG_valist (GST_CAT_DEFAULT, GST_LEVEL_DEBUG, obj, format, |
---|
521 | varargs); |
---|
522 | va_end (varargs); |
---|
523 | } |
---|
524 | |
---|
525 | static inline void |
---|
526 | GST_LOG_OBJECT (gpointer obj, const char *format, ...) |
---|
527 | { |
---|
528 | va_list varargs; |
---|
529 | |
---|
530 | va_start (varargs, format); |
---|
531 | GST_CAT_LEVEL_LOG_valist (GST_CAT_DEFAULT, GST_LEVEL_LOG, obj, format, |
---|
532 | varargs); |
---|
533 | va_end (varargs); |
---|
534 | } |
---|
535 | |
---|
536 | static inline void |
---|
537 | GST_ERROR (const char *format, ...) |
---|
538 | { |
---|
539 | va_list varargs; |
---|
540 | |
---|
541 | va_start (varargs, format); |
---|
542 | GST_CAT_LEVEL_LOG_valist (GST_CAT_DEFAULT, GST_LEVEL_ERROR, NULL, format, |
---|
543 | varargs); |
---|
544 | va_end (varargs); |
---|
545 | } |
---|
546 | |
---|
547 | static inline void |
---|
548 | GST_WARNING (const char *format, ...) |
---|
549 | { |
---|
550 | va_list varargs; |
---|
551 | |
---|
552 | va_start (varargs, format); |
---|
553 | GST_CAT_LEVEL_LOG_valist (GST_CAT_DEFAULT, GST_LEVEL_WARNING, NULL, format, |
---|
554 | varargs); |
---|
555 | va_end (varargs); |
---|
556 | } |
---|
557 | |
---|
558 | static inline void |
---|
559 | GST_INFO (const char *format, ...) |
---|
560 | { |
---|
561 | va_list varargs; |
---|
562 | |
---|
563 | va_start (varargs, format); |
---|
564 | GST_CAT_LEVEL_LOG_valist (GST_CAT_DEFAULT, GST_LEVEL_INFO, NULL, format, |
---|
565 | varargs); |
---|
566 | va_end (varargs); |
---|
567 | } |
---|
568 | |
---|
569 | static inline void |
---|
570 | GST_DEBUG (const char *format, ...) |
---|
571 | { |
---|
572 | va_list varargs; |
---|
573 | |
---|
574 | va_start (varargs, format); |
---|
575 | GST_CAT_LEVEL_LOG_valist (GST_CAT_DEFAULT, GST_LEVEL_DEBUG, NULL, format, |
---|
576 | varargs); |
---|
577 | va_end (varargs); |
---|
578 | } |
---|
579 | |
---|
580 | static inline void |
---|
581 | GST_LOG (const char *format, ...) |
---|
582 | { |
---|
583 | va_list varargs; |
---|
584 | |
---|
585 | va_start (varargs, format); |
---|
586 | GST_CAT_LEVEL_LOG_valist (GST_CAT_DEFAULT, GST_LEVEL_LOG, NULL, |
---|
587 | format, varargs); |
---|
588 | va_end (varargs); |
---|
589 | } |
---|
590 | #endif |
---|
591 | #endif |
---|
592 | |
---|
593 | |
---|
594 | /********** function pointer stuff **********/ |
---|
595 | void * _gst_debug_register_funcptr (void * ptr, |
---|
596 | gchar * ptrname); |
---|
597 | G_CONST_RETURN gchar * |
---|
598 | _gst_debug_nameof_funcptr (void * ptr); |
---|
599 | |
---|
600 | #define GST_DEBUG_FUNCPTR(ptr) (_gst_debug_register_funcptr((void *)(ptr), #ptr) , ptr) |
---|
601 | #define GST_DEBUG_FUNCPTR_NAME(ptr) _gst_debug_nameof_funcptr((void *)ptr) |
---|
602 | |
---|
603 | #else /* GST_DISABLE_GST_DEBUG */ |
---|
604 | |
---|
605 | #if defined(__GNUC__) && __GNUC__ >= 3 |
---|
606 | # pragma GCC poison gst_debug_log |
---|
607 | # pragma GCC poison gst_debug_log_valist |
---|
608 | # pragma GCC poison _gst_debug_category_new |
---|
609 | #endif |
---|
610 | |
---|
611 | #define _gst_debug_init() /* NOP */ |
---|
612 | |
---|
613 | #define gst_debug_set_log_function(func,data) /* NOP */ |
---|
614 | #define gst_debug_reset_log_function(void) /* NOP */ |
---|
615 | #define gst_debug_set_default_threshold(level) /* NOP */ |
---|
616 | #define gst_debug_get_default_threshold() (GST_LEVEL_NONE) |
---|
617 | |
---|
618 | #define gst_debug_level_get_name(level) ("NONE") |
---|
619 | #define gst_debug_add_log_function(func,data) (FALSE) |
---|
620 | #define gst_debug_remove_log_function(func) (0) |
---|
621 | #define gst_debug_remove_log_function_by_data(data) (0) |
---|
622 | #define gst_debug_set_active(active) /* NOP */ |
---|
623 | #define gst_debug_is_active() (FALSE) |
---|
624 | #define gst_debug_set_colored(colored) /* NOP */ |
---|
625 | #define gst_debug_is_colored() (FALSE) |
---|
626 | #define gst_debug_set_default_threshold(level) /* NOP */ |
---|
627 | #define gst_debug_get_default_threshold() (GST_LEVEL_NONE) |
---|
628 | #define gst_debug_set_threshold_for_name(name,level) /* NOP */ |
---|
629 | #define gst_debug_unset_threshold_for_name(name) /* NOP */ |
---|
630 | |
---|
631 | #define GST_DEBUG_CATEGORY(var) /* NOP */ |
---|
632 | #define GST_DEBUG_CATEGORY_EXTERN(var) /* NOP */ |
---|
633 | #if !defined(G_HAVE_GNUC_VARARGS) && !defined(G_HAVE_ISO_VARARGS) |
---|
634 | #define GST_DEBUG_CATEGORY_STATIC(var) static GstDebugCategory *var = NULL |
---|
635 | #else |
---|
636 | #define GST_DEBUG_CATEGORY_STATIC(var) /* NOP */ |
---|
637 | #endif |
---|
638 | #define GST_DEBUG_CATEGORY_INIT(var,name,color,desc) /* NOP */ |
---|
639 | #define gst_debug_category_free(category) /* NOP */ |
---|
640 | #define gst_debug_category_set_threshold(category,level) /* NOP */ |
---|
641 | #define gst_debug_category_reset_threshold(category) /* NOP */ |
---|
642 | #define gst_debug_category_get_threshold(category) (GST_LEVEL_NONE) |
---|
643 | #define gst_debug_category_get_name(cat) ("") |
---|
644 | #define gst_debug_category_get_color(cat) (0) |
---|
645 | #define gst_debug_category_get_description(cat) ("") |
---|
646 | #define gst_debug_get_all_categories() (NULL) |
---|
647 | #define gst_debug_construct_term_color(colorinfo) (g_strdup ("00")) |
---|
648 | |
---|
649 | #ifdef G_HAVE_ISO_VARARGS |
---|
650 | |
---|
651 | #define GST_CAT_LEVEL_LOG(cat,level,...) /* NOP */ |
---|
652 | |
---|
653 | #define GST_CAT_ERROR_OBJECT(...) /* NOP */ |
---|
654 | #define GST_CAT_WARNING_OBJECT(...) /* NOP */ |
---|
655 | #define GST_CAT_INFO_OBJECT(...) /* NOP */ |
---|
656 | #define GST_CAT_DEBUG_OBJECT(...) /* NOP */ |
---|
657 | #define GST_CAT_LOG_OBJECT(...) /* NOP */ |
---|
658 | |
---|
659 | #define GST_CAT_ERROR(...) /* NOP */ |
---|
660 | #define GST_CAT_WARNING(...) /* NOP */ |
---|
661 | #define GST_CAT_INFO(...) /* NOP */ |
---|
662 | #define GST_CAT_DEBUG(...) /* NOP */ |
---|
663 | #define GST_CAT_LOG(...) /* NOP */ |
---|
664 | |
---|
665 | #define GST_ERROR_OBJECT(...) /* NOP */ |
---|
666 | #define GST_WARNING_OBJECT(...) /* NOP */ |
---|
667 | #define GST_INFO_OBJECT(...) /* NOP */ |
---|
668 | #define GST_DEBUG_OBJECT(...) /* NOP */ |
---|
669 | #define GST_LOG_OBJECT(...) /* NOP */ |
---|
670 | |
---|
671 | #define GST_ERROR(...) /* NOP */ |
---|
672 | #define GST_WARNING(...) /* NOP */ |
---|
673 | #define GST_INFO(...) /* NOP */ |
---|
674 | #define GST_DEBUG(...) /* NOP */ |
---|
675 | #define GST_LOG(...) /* NOP */ |
---|
676 | |
---|
677 | #else |
---|
678 | #ifdef G_HAVE_GNUC_VARARGS |
---|
679 | |
---|
680 | #define GST_CAT_LEVEL_LOG(cat,level,args...) /* NOP */ |
---|
681 | |
---|
682 | #define GST_CAT_ERROR_OBJECT(args...) /* NOP */ |
---|
683 | #define GST_CAT_WARNING_OBJECT(args...) /* NOP */ |
---|
684 | #define GST_CAT_INFO_OBJECT(args...) /* NOP */ |
---|
685 | #define GST_CAT_DEBUG_OBJECT(args...) /* NOP */ |
---|
686 | #define GST_CAT_LOG_OBJECT(args...) /* NOP */ |
---|
687 | |
---|
688 | #define GST_CAT_ERROR(args...) /* NOP */ |
---|
689 | #define GST_CAT_WARNING(args...) /* NOP */ |
---|
690 | #define GST_CAT_INFO(args...) /* NOP */ |
---|
691 | #define GST_CAT_DEBUG(args...) /* NOP */ |
---|
692 | #define GST_CAT_LOG(args...) /* NOP */ |
---|
693 | |
---|
694 | #define GST_ERROR_OBJECT(args...) /* NOP */ |
---|
695 | #define GST_WARNING_OBJECT(args...) /* NOP */ |
---|
696 | #define GST_INFO_OBJECT(args...) /* NOP */ |
---|
697 | #define GST_DEBUG_OBJECT(args...) /* NOP */ |
---|
698 | #define GST_LOG_OBJECT(args...) /* NOP */ |
---|
699 | |
---|
700 | #define GST_ERROR(args...) /* NOP */ |
---|
701 | #define GST_WARNING(args...) /* NOP */ |
---|
702 | #define GST_INFO(args...) /* NOP */ |
---|
703 | #define GST_DEBUG(args...) /* NOP */ |
---|
704 | #define GST_LOG(args...) /* NOP */ |
---|
705 | |
---|
706 | #else |
---|
707 | static inline void |
---|
708 | GST_CAT_LEVEL_LOG_valist (GstDebugCategory * cat, |
---|
709 | GstDebugLevel level, gpointer object, const char *format, va_list varargs) |
---|
710 | { |
---|
711 | } |
---|
712 | |
---|
713 | static inline void |
---|
714 | GST_CAT_ERROR_OBJECT (GstDebugCategory * cat, gpointer obj, const char *format, |
---|
715 | ...) |
---|
716 | { |
---|
717 | } |
---|
718 | |
---|
719 | static inline void |
---|
720 | GST_CAT_WARNING_OBJECT (GstDebugCategory * cat, gpointer obj, |
---|
721 | const char *format, ...) |
---|
722 | { |
---|
723 | } |
---|
724 | |
---|
725 | static inline void |
---|
726 | GST_CAT_INFO_OBJECT (GstDebugCategory * cat, gpointer obj, const char *format, |
---|
727 | ...) |
---|
728 | { |
---|
729 | } |
---|
730 | |
---|
731 | static inline void |
---|
732 | GST_CAT_DEBUG_OBJECT (GstDebugCategory * cat, gpointer obj, const char *format, |
---|
733 | ...) |
---|
734 | { |
---|
735 | } |
---|
736 | |
---|
737 | static inline void |
---|
738 | GST_CAT_LOG_OBJECT (GstDebugCategory * cat, gpointer obj, const char *format, |
---|
739 | ...) |
---|
740 | { |
---|
741 | } |
---|
742 | |
---|
743 | static inline void |
---|
744 | GST_CAT_ERROR (GstDebugCategory * cat, const char *format, ...) |
---|
745 | { |
---|
746 | } |
---|
747 | |
---|
748 | static inline void |
---|
749 | GST_CAT_WARNING (GstDebugCategory * cat, const char *format, ...) |
---|
750 | { |
---|
751 | } |
---|
752 | |
---|
753 | static inline void |
---|
754 | GST_CAT_INFO (GstDebugCategory * cat, const char *format, ...) |
---|
755 | { |
---|
756 | } |
---|
757 | |
---|
758 | static inline void |
---|
759 | GST_CAT_DEBUG (GstDebugCategory * cat, const char *format, ...) |
---|
760 | { |
---|
761 | } |
---|
762 | |
---|
763 | static inline void |
---|
764 | GST_CAT_LOG (GstDebugCategory * cat, const char *format, ...) |
---|
765 | { |
---|
766 | } |
---|
767 | |
---|
768 | static inline void |
---|
769 | GST_ERROR_OBJECT (gpointer obj, const char *format, ...) |
---|
770 | { |
---|
771 | } |
---|
772 | |
---|
773 | static inline void |
---|
774 | GST_WARNING_OBJECT (gpointer obj, const char *format, ...) |
---|
775 | { |
---|
776 | } |
---|
777 | |
---|
778 | static inline void |
---|
779 | GST_INFO_OBJECT (gpointer obj, const char *format, ...) |
---|
780 | { |
---|
781 | } |
---|
782 | |
---|
783 | static inline void |
---|
784 | GST_DEBUG_OBJECT (gpointer obj, const char *format, ...) |
---|
785 | { |
---|
786 | } |
---|
787 | |
---|
788 | static inline void |
---|
789 | GST_LOG_OBJECT (gpointer obj, const char *format, ...) |
---|
790 | { |
---|
791 | } |
---|
792 | |
---|
793 | static inline void |
---|
794 | GST_ERROR (const char *format, ...) |
---|
795 | { |
---|
796 | } |
---|
797 | |
---|
798 | static inline void |
---|
799 | GST_WARNING (const char *format, ...) |
---|
800 | { |
---|
801 | } |
---|
802 | |
---|
803 | static inline void |
---|
804 | GST_INFO (const char *format, ...) |
---|
805 | { |
---|
806 | } |
---|
807 | |
---|
808 | static inline void |
---|
809 | GST_DEBUG (const char *format, ...) |
---|
810 | { |
---|
811 | } |
---|
812 | |
---|
813 | static inline void |
---|
814 | GST_LOG (const char *format, ...) |
---|
815 | { |
---|
816 | } |
---|
817 | #endif |
---|
818 | #endif |
---|
819 | |
---|
820 | #define GST_DEBUG_FUNCPTR(ptr) (ptr) |
---|
821 | #define GST_DEBUG_FUNCPTR_NAME(ptr) (g_strdup_printf ("%p", ptr)) |
---|
822 | |
---|
823 | #endif /* GST_DISABLE_GST_DEBUG */ |
---|
824 | |
---|
825 | void gst_debug_print_stack_trace (void); |
---|
826 | |
---|
827 | /* timestamp debugging macros */ |
---|
828 | /* FIXME 0.9: move into the correct header (gstclock.h) */ |
---|
829 | #define GST_TIME_FORMAT "u:%02u:%02u.%09u" |
---|
830 | #define GST_TIME_ARGS(t) \ |
---|
831 | (guint) ((t) / (GST_SECOND * 60 * 60)), \ |
---|
832 | (guint) (((t) / (GST_SECOND * 60)) % 60), \ |
---|
833 | (guint) (((t) / GST_SECOND) % 60), \ |
---|
834 | (guint) ((t) % GST_SECOND) |
---|
835 | |
---|
836 | G_END_DECLS |
---|
837 | |
---|
838 | #endif /* __GSTINFO_H__ */ |
---|