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 */
24 #ifndef __GSTINFO_H__
25 #define __GSTINFO_H__
27 #include <glib.h>
28 #include <glib-object.h>
29 #include <gst/gstconfig.h>
31 G_BEGIN_DECLS
33 /**
34 * GstDebugLevel:
35 * @GST_LEVEL_NONE: No debugging level specified or desired. Used to deactivate
36 * debugging output.
37 * @GST_LEVEL_ERROR: Error messages are to be used only when an error occured
38 * that stops the application from keeping working correctly.
39 * An examples is gst_element_error, which outputs a message with this priority.
40 * It does not mean that the application is terminating as with g_errror.
41 * @GST_LEVEL_WARNING: Warning messages are to inform about abnormal behaviour
42 * that could lead to problems or weird behaviour later on. An example of this
43 * would be clocking issues ("your computer is pretty slow") or broken input
44 * data ("Can't synchronize to stream.")
45 * @GST_LEVEL_INFO: Informational messages should be used to keep the developer
46 * updated about what is happening.
47 * Examples where this should be used are when a typefind function has
48 * successfully determined the type of the stream or when an mp3 plugin detects
49 * the format to be used. ("This file has mono sound.")
50 * @GST_LEVEL_DEBUG: Debugging messages should be used when something common
51 * happens that is not the expected default behavior.
52 * An example would be notifications about state changes or receiving/sending of
53 * events.
54 * @GST_LEVEL_LOG: Log messages are messages that are very common but might be
55 * useful to know. As a rule of thumb a pipeline that is iterating as expected
56 * should never output anzthing else but LOG messages.
57 * Examples for this are referencing/dereferencing of objects or cothread switches.
58 * @GST_LEVEL_COUNT: The number of defined debugging levels.
59 *
60 * The level defines the importance of a debugging message. The more important a
61 * message is, the greater the probability that the debugging system outputs it.
62 */
63 typedef enum {
64 GST_LEVEL_NONE = 0,
65 GST_LEVEL_ERROR,
66 GST_LEVEL_WARNING,
67 GST_LEVEL_INFO,
68 GST_LEVEL_DEBUG,
69 GST_LEVEL_LOG,
70 /* add more */
71 GST_LEVEL_COUNT
72 } GstDebugLevel;
74 /**
75 * GST_LEVEL_DEFAULT:
76 *
77 * Defines the default debugging level to be used with GStreamer. It is normally
78 * set to #GST_LEVEL_NONE so nothing get printed.
79 * As it can be configured at compile time, developer builds may chose to
80 * override that though.
81 * You can use this as an argument to gst_debug_set_default_threshold() to
82 * reset the debugging output to default behaviour.
83 */
84 #ifndef GST_LEVEL_DEFAULT
85 #define GST_LEVEL_DEFAULT GST_LEVEL_NONE
86 #endif
88 /* defines for format (colors etc)
89 * don't change them around, it uses terminal layout
90 * Terminal color strings:
91 * 00=none 01=bold 04=underscore 05=blink 07=reverse 08=concealed
92 * Text color codes:
93 * 30=black 31=red 32=green 33=yellow 34=blue 35=magenta 36=cyan 37=white
94 * Background color codes:
95 * 40=black 41=red 42=green 43=yellow 44=blue 45=magenta 46=cyan 47=white
96 */
97 /**
98 * GstDebugColorFlags:
99 * @GST_DEBUG_FG_BLACK: Use black as foreground color.
100 * @GST_DEBUG_FG_RED: Use red as foreground color.
101 * @GST_DEBUG_FG_GREEN: Use green as foreground color.
102 * @GST_DEBUG_FG_YELLOW: Use yellow as foreground color.
103 * @GST_DEBUG_FG_BLUE: Use blue as foreground color.
104 * @GST_DEBUG_FG_MAGENTA: Use magenta as foreground color.
105 * @GST_DEBUG_FG_CYAN: Use cyan as foreground color.
106 * @GST_DEBUG_FG_WHITE: Use white as foreground color.
107 * @GST_DEBUG_BG_BLACK: Use black as background color.
108 * @GST_DEBUG_BG_RED: Use red as background color.
109 * @GST_DEBUG_BG_GREEN: Use green as background color.
110 * @GST_DEBUG_BG_YELLOW: Use yellow as background color.
111 * @GST_DEBUG_BG_BLUE: Use blue as background color.
112 * @GST_DEBUG_BG_MAGENTA: Use magenta as background color.
113 * @GST_DEBUG_BG_CYAN: Use cyan as background color.
114 * @GST_DEBUG_BG_WHITE: Use white as background color.
115 * @GST_DEBUG_BOLD: Make the output bold.
116 * @GST_DEBUG_UNDERLINE: Underline the output.
117 *
118 * These are some terminal style flags you can use when creating your
119 * debugging categories to make them stand out in debugging output.
120 */
121 typedef enum {
122 /* colors */
123 GST_DEBUG_FG_BLACK = 0x0000,
124 GST_DEBUG_FG_RED = 0x0001,
125 GST_DEBUG_FG_GREEN = 0x0002,
126 GST_DEBUG_FG_YELLOW = 0x0003,
127 GST_DEBUG_FG_BLUE = 0x0004,
128 GST_DEBUG_FG_MAGENTA = 0x0005,
129 GST_DEBUG_FG_CYAN = 0x0006,
130 GST_DEBUG_FG_WHITE = 0x0007,
131 /* background colors */
132 GST_DEBUG_BG_BLACK = 0x0000,
133 GST_DEBUG_BG_RED = 0x0010,
134 GST_DEBUG_BG_GREEN = 0x0020,
135 GST_DEBUG_BG_YELLOW = 0x0030,
136 GST_DEBUG_BG_BLUE = 0x0040,
137 GST_DEBUG_BG_MAGENTA = 0x0050,
138 GST_DEBUG_BG_CYAN = 0x0060,
139 GST_DEBUG_BG_WHITE = 0x0070,
140 /* other formats */
141 GST_DEBUG_BOLD = 0x0100,
142 GST_DEBUG_UNDERLINE = 0x0200
143 } GstDebugColorFlags;
145 #define GST_DEBUG_FG_MASK (0x000F)
146 #define GST_DEBUG_BG_MASK (0x00F0)
147 #define GST_DEBUG_FORMAT_MASK (0xFF00)
149 typedef struct _GstDebugCategory GstDebugCategory;
150 /**
151 * GstDebugCategory:
152 *
153 * This is the struct that describes the categories. Once initialized with
154 * #GST_DEBUG_CATEGORY_INIT, its values can't be changed anymore.
155 */
156 struct _GstDebugCategory {
157 /*< private >*/
158 gint threshold;
159 guint color; /* see defines above */
161 const gchar * name;
162 const gchar * description;
163 };
165 /********** some convenience macros for debugging **********/
167 /**
168 * GST_STR_NULL:
169 * @str: The string to check.
170 *
171 * Macro to use when a string must not be NULL, but may be NULL. If the string
172 * is NULL, "(NULL)" is printed instead.
173 * In GStreamer printf string arguments may not be NULL, because on some
174 * platforms (ie Solaris) the libc crashes in that case. This includes debugging
175 * strings.
176 */
177 #define GST_STR_NULL(str) ((str) ? (str) : "(NULL)")
179 /* FIXME, not MT safe */
180 /**
181 * GST_DEBUG_PAD_NAME:
182 * @pad: The pad to debug.
183 *
184 * Evaluates to 2 strings, that describe the pad. Often used in debugging
185 * statements.
186 */
187 #define GST_DEBUG_PAD_NAME(pad) \
188 (pad != NULL) ? \
189 ((GST_OBJECT_PARENT(pad) != NULL) ? \
190 GST_STR_NULL (GST_OBJECT_NAME (GST_OBJECT_PARENT(pad))) : \
191 "''" ) : "''", \
192 (pad != NULL) ? GST_STR_NULL (GST_OBJECT_NAME (pad)) : "''"
194 /**
195 * GST_FUNCTION:
196 *
197 * This macro should evaluate to the name of the current function and be should
198 * be defined when configuring your project, as it is compiler dependant. If it
199 * is not defined, some default value is used. It is used to provide debugging
200 * output with the function name of the message.
201 */
202 #ifndef GST_FUNCTION
203 #if defined (__GNUC__)
204 # define GST_FUNCTION ((const char*) (__PRETTY_FUNCTION__))
205 #elif defined (G_HAVE_ISO_VARARGS)
206 # define GST_FUNCTION ((const char*) (__func__))
207 #else
208 # define GST_FUNCTION ((const char*) ("???"))
209 #endif
210 #endif /* ifndef GST_FUNCTION */
213 typedef struct _GstDebugMessage GstDebugMessage;
215 /**
216 * GstLogFunction:
217 * @category: a #GstDebugCategory
218 * @level: a #GstDebugLevel
219 * @file: file name
220 * @function: function name
221 * @line: line number
222 * @object: a #GObject
223 * @message: the message
224 * @data: user data for the log function
225 *
226 * Function prototype for a logging function that can be registered with
227 * gst_debug_add_log_function().
228 * Use G_GNUC_NO_INSTRUMENT on that function.
229 */
230 typedef void (*GstLogFunction) (GstDebugCategory * category,
231 GstDebugLevel level,
232 const gchar * file,
233 const gchar * function,
234 gint line,
235 GObject * object,
236 GstDebugMessage * message,
237 gpointer data);
239 #ifndef GST_DISABLE_GST_DEBUG
241 void _gst_debug_init (void);
243 /* note we can't use G_GNUC_PRINTF (7, 8) because gcc chokes on %P, which
244 * we use for GST_PTR_FORMAT. */
245 void gst_debug_log (GstDebugCategory * category,
246 GstDebugLevel level,
247 const gchar * file,
248 const gchar * function,
249 gint line,
250 GObject * object,
251 const gchar * format,
252 ...) G_GNUC_NO_INSTRUMENT;
253 void gst_debug_log_valist (GstDebugCategory * category,
254 GstDebugLevel level,
255 const gchar * file,
256 const gchar * function,
257 gint line,
258 GObject * object,
259 const gchar * format,
260 va_list args) G_GNUC_NO_INSTRUMENT;
262 const gchar * gst_debug_message_get (GstDebugMessage * message);
264 void gst_debug_log_default (GstDebugCategory * category,
265 GstDebugLevel level,
266 const gchar * file,
267 const gchar * function,
268 gint line,
269 GObject * object,
270 GstDebugMessage * message,
271 gpointer unused) G_GNUC_NO_INSTRUMENT;
273 G_CONST_RETURN gchar *
274 gst_debug_level_get_name (GstDebugLevel level);
276 void gst_debug_add_log_function (GstLogFunction func,
277 gpointer data);
278 guint gst_debug_remove_log_function (GstLogFunction func);
279 guint gst_debug_remove_log_function_by_data (gpointer data);
281 void gst_debug_set_active (gboolean active);
282 gboolean gst_debug_is_active (void);
284 void gst_debug_set_colored (gboolean colored);
285 gboolean gst_debug_is_colored (void);
287 void gst_debug_set_default_threshold (GstDebugLevel level);
288 GstDebugLevel gst_debug_get_default_threshold (void);
289 void gst_debug_set_threshold_for_name (const gchar * name,
290 GstDebugLevel level);
291 void gst_debug_unset_threshold_for_name (const gchar * name);
293 /**
294 * GST_DEBUG_CATEGORY:
295 * @cat: the category
296 *
297 * Defines a GstDebugCategory variable.
298 * This macro expands to nothing if debugging is disabled.
299 */
300 #define GST_DEBUG_CATEGORY(cat) GstDebugCategory *cat = NULL
301 /**
302 * GST_DEBUG_CATEGORY_EXTERN:
303 * @cat: the category
304 *
305 * Declares a GstDebugCategory variable as extern. Use in header files.
306 * This macro expands to nothing if debugging is disabled.
307 */
308 #define GST_DEBUG_CATEGORY_EXTERN(cat) extern GstDebugCategory *cat
309 /**
310 * GST_DEBUG_CATEGORY_STATIC:
311 * @cat: the category
312 *
313 * Defines a static GstDebugCategory variable.
314 * This macro expands to nothing if debugging is disabled.
315 */
316 #define GST_DEBUG_CATEGORY_STATIC(cat) static GstDebugCategory *cat = NULL
317 /* do not use this function, use the macros below */
318 GstDebugCategory *_gst_debug_category_new (gchar * name,
319 guint color,
320 gchar * description);
321 /**
322 * GST_DEBUG_CATEGORY_INIT:
323 * @cat: the category to initialize.
324 * @name: the name of the category.
325 * @color: the colors to use for a color representation or 0 for no color.
326 * @description: optional description of the category.
327 *
328 * Initializes a new #GstDebugCategory with the given properties and set to
329 * the default threshold.
330 *
331 * <note>
332 * <para>
333 * This macro expands to nothing if debugging is disabled.
334 * </para>
335 * <para>
336 * When naming your category, please follow the following conventions to ensure
337 * that the pattern matching for categories works as expected. It is not
338 * earth-shattering if you don't follow these conventions, but it would be nice
339 * for everyone.
340 * </para>
341 * <para>
342 * If you define a category for a plugin or a feature of it, name the category
343 * like the feature. So if you wanted to write a "filesrc" element, you would
344 * name the category "filesrc". Use lowercase letters only.
345 * If you define more than one category for the same element, append an
346 * underscore and an identifier to your categories, like this: "filesrc_cache"
347 * </para>
348 * <para>
349 * If you create a library or an application using debugging categories, use a
350 * common prefix followed by an underscore for all your categories. GStreamer
351 * uses the GST prefix so GStreamer categories look like "GST_STATES". Be sure
352 * to include uppercase letters.
353 * </para>
354 * </note>
355 */
356 #define GST_DEBUG_CATEGORY_INIT(cat,name,color,description) G_STMT_START{\
357 if (cat == NULL) \
358 cat = _gst_debug_category_new (name,color,description); \
359 }G_STMT_END
361 void gst_debug_category_free (GstDebugCategory * category);
362 void gst_debug_category_set_threshold (GstDebugCategory * category,
363 GstDebugLevel level);
364 void gst_debug_category_reset_threshold(GstDebugCategory * category);
365 GstDebugLevel
366 gst_debug_category_get_threshold (GstDebugCategory * category);
367 G_CONST_RETURN gchar *
368 gst_debug_category_get_name (GstDebugCategory * category);
369 guint gst_debug_category_get_color (GstDebugCategory * category);
370 G_CONST_RETURN gchar *
371 gst_debug_category_get_description (GstDebugCategory * category);
372 GSList *
373 gst_debug_get_all_categories (void);
375 gchar * gst_debug_construct_term_color (guint colorinfo);
378 /**
379 * GST_CAT_DEFAULT:
380 *
381 * Default gstreamer core debug log category. Please define your own.
382 */
383 GST_EXPORT GstDebugCategory * GST_CAT_DEFAULT;
384 /* this symbol may not be used */
385 extern gboolean __gst_debug_enabled;
387 /**
388 * GST_CAT_LEVEL_LOG:
389 * @cat: category to use
390 * @level: the severity of the message
391 * @object: the #GObject the message belongs to or NULL if none
392 * @...: A printf-style message to output
393 *
394 * Outputs a debugging message. This is the most general macro for outputting
395 * debugging messages. You will probably want to use one of the ones described
396 * below.
397 */
398 #ifdef G_HAVE_ISO_VARARGS
399 #define GST_CAT_LEVEL_LOG(cat,level,object,...) G_STMT_START{ \
400 if (__gst_debug_enabled) { \
401 gst_debug_log ((cat), (level), __FILE__, GST_FUNCTION, __LINE__, \
402 (GObject *) (object), __VA_ARGS__); \
403 } \
404 }G_STMT_END
405 #else /* G_HAVE_GNUC_VARARGS */
406 #ifdef G_HAVE_GNUC_VARARGS
407 #define GST_CAT_LEVEL_LOG(cat,level,object,args...) G_STMT_START{ \
408 if (__gst_debug_enabled) { \
409 gst_debug_log ((cat), (level), __FILE__, GST_FUNCTION, __LINE__, \
410 (GObject *) (object), ##args ); \
411 } \
412 }G_STMT_END
413 #else /* no variadic macros, use inline */
414 static inline void
415 GST_CAT_LEVEL_LOG_valist (GstDebugCategory * cat,
416 GstDebugLevel level, gpointer object, const char *format, va_list varargs)
417 {
418 gst_debug_log_valist (cat, level, "", "", 0, (GObject *) object, format,
419 varargs);
420 }
422 static inline void
423 GST_CAT_LEVEL_LOG (GstDebugCategory * cat, GstDebugLevel level,
424 gpointer object, const char *format, ...)
425 {
426 if (__gst_debug_enabled) {
427 va_list varargs;
429 va_start (varargs, format);
430 GST_CAT_LEVEL_LOG_valist (cat, level, object, format, varargs);
431 va_end (varargs);
432 }
433 }
434 #endif
435 #endif /* G_HAVE_ISO_VARARGS */
437 /**
438 * GST_CAT_ERROR_OBJECT:
439 * @cat: category to use
440 * @obj: the #GObject the message belongs to
441 * @...: printf-style message to output
442 *
443 * Output an error message belonging to the given object in the given category.
444 */
445 /**
446 * GST_CAT_WARNING_OBJECT:
447 * @cat: category to use
448 * @obj: the #GObject the message belongs to
449 * @...: printf-style message to output
450 *
451 * Output a warning message belonging to the given object in the given category.
452 */
453 /**
454 * GST_CAT_INFO_OBJECT:
455 * @cat: category to use
456 * @obj: the #GObject the message belongs to
457 * @...: printf-style message to output
458 *
459 * Output an informational message belonging to the given object in the given
460 * category.
461 */
462 /**
463 * GST_CAT_DEBUG_OBJECT:
464 * @cat: category to use
465 * @obj: the #GObject the message belongs to
466 * @...: printf-style message to output
467 *
468 * Output an debugging message belonging to the given object in the given category.
469 */
470 /**
471 * GST_CAT_LOG_OBJECT:
472 * @cat: category to use
473 * @obj: the #GObject the message belongs to
474 * @...: printf-style message to output
475 *
476 * Output an logging message belonging to the given object in the given category.
477 */
480 /**
481 * GST_CAT_ERROR:
482 * @cat: category to use
483 * @...: printf-style message to output
484 *
485 * Output an error message in the given category.
486 */
487 /**
488 * GST_CAT_WARNING:
489 * @cat: category to use
490 * @...: printf-style message to output
491 *
492 * Output an warning message in the given category.
493 */
494 /**
495 * GST_CAT_INFO:
496 * @cat: category to use
497 * @...: printf-style message to output
498 *
499 * Output an informational message in the given category.
500 */
501 /**
502 * GST_CAT_DEBUG:
503 * @cat: category to use
504 * @...: printf-style message to output
505 *
506 * Output an debugging message in the given category.
507 */
508 /**
509 * GST_CAT_LOG:
510 * @cat: category to use
511 * @...: printf-style message to output
512 *
513 * Output an logging message in the given category.
514 */
517 /**
518 * GST_ERROR_OBJECT:
519 * @obj: the #GObject the message belongs to
520 * @...: printf-style message to output
521 *
522 * Output an error message belonging to the given object in the default category.
523 */
524 /**
525 * GST_WARNING_OBJECT:
526 * @obj: the #GObject the message belongs to
527 * @...: printf-style message to output
528 *
529 * Output a warning message belonging to the given object in the default category.
530 */
531 /**
532 * GST_INFO_OBJECT:
533 * @obj: the #GObject the message belongs to
534 * @...: printf-style message to output
535 *
536 * Output an informational message belonging to the given object in the default
537 * category.
538 */
539 /**
540 * GST_DEBUG_OBJECT:
541 * @obj: the #GObject the message belongs to
542 * @...: printf-style message to output
543 *
544 * Output a debugging message belonging to the given object in the default
545 * category.
546 */
547 /**
548 * GST_LOG_OBJECT:
549 * @obj: the #GObject the message belongs to
550 * @...: printf-style message to output
551 *
552 * Output a logging message belonging to the given object in the default category.
553 */
556 /**
557 * GST_ERROR:
558 * @...: printf-style message to output
559 *
560 * Output an error message in the default category.
561 */
562 /**
563 * GST_WARNING:
564 * @...: printf-style message to output
565 *
566 * Output a warning message in the default category.
567 */
568 /**
569 * GST_INFO:
570 * @...: printf-style message to output
571 *
572 * Output an informational message in the default category.
573 */
574 /**
575 * GST_DEBUG:
576 * @...: printf-style message to output
577 *
578 * Output a debugging message in the default category.
579 */
580 /**
581 * GST_LOG:
582 * @...: printf-style message to output
583 *
584 * Output a logging message in the default category.
585 */
587 #ifdef G_HAVE_ISO_VARARGS
589 #define GST_CAT_ERROR_OBJECT(cat,obj,...) GST_CAT_LEVEL_LOG (cat, GST_LEVEL_ERROR, obj, __VA_ARGS__)
590 #define GST_CAT_WARNING_OBJECT(cat,obj,...) GST_CAT_LEVEL_LOG (cat, GST_LEVEL_WARNING, obj, __VA_ARGS__)
591 #define GST_CAT_INFO_OBJECT(cat,obj,...) GST_CAT_LEVEL_LOG (cat, GST_LEVEL_INFO, obj, __VA_ARGS__)
592 #define GST_CAT_DEBUG_OBJECT(cat,obj,...) GST_CAT_LEVEL_LOG (cat, GST_LEVEL_DEBUG, obj, __VA_ARGS__)
593 #define GST_CAT_LOG_OBJECT(cat,obj,...) GST_CAT_LEVEL_LOG (cat, GST_LEVEL_LOG, obj, __VA_ARGS__)
595 #define GST_CAT_ERROR(cat,...) GST_CAT_LEVEL_LOG (cat, GST_LEVEL_ERROR, NULL, __VA_ARGS__)
596 #define GST_CAT_WARNING(cat,...) GST_CAT_LEVEL_LOG (cat, GST_LEVEL_WARNING, NULL, __VA_ARGS__)
597 #define GST_CAT_INFO(cat,...) GST_CAT_LEVEL_LOG (cat, GST_LEVEL_INFO, NULL, __VA_ARGS__)
598 #define GST_CAT_DEBUG(cat,...) GST_CAT_LEVEL_LOG (cat, GST_LEVEL_DEBUG, NULL, __VA_ARGS__)
599 #define GST_CAT_LOG(cat,...) GST_CAT_LEVEL_LOG (cat, GST_LEVEL_LOG, NULL, __VA_ARGS__)
601 #define GST_ERROR_OBJECT(obj,...) GST_CAT_LEVEL_LOG (GST_CAT_DEFAULT, GST_LEVEL_ERROR, obj, __VA_ARGS__)
602 #define GST_WARNING_OBJECT(obj,...) GST_CAT_LEVEL_LOG (GST_CAT_DEFAULT, GST_LEVEL_WARNING, obj, __VA_ARGS__)
603 #define GST_INFO_OBJECT(obj,...) GST_CAT_LEVEL_LOG (GST_CAT_DEFAULT, GST_LEVEL_INFO, obj, __VA_ARGS__)
604 #define GST_DEBUG_OBJECT(obj,...) GST_CAT_LEVEL_LOG (GST_CAT_DEFAULT, GST_LEVEL_DEBUG, obj, __VA_ARGS__)
605 #define GST_LOG_OBJECT(obj,...) GST_CAT_LEVEL_LOG (GST_CAT_DEFAULT, GST_LEVEL_LOG, obj, __VA_ARGS__)
607 #define GST_ERROR(...) GST_CAT_LEVEL_LOG (GST_CAT_DEFAULT, GST_LEVEL_ERROR, NULL, __VA_ARGS__)
608 #define GST_WARNING(...) GST_CAT_LEVEL_LOG (GST_CAT_DEFAULT, GST_LEVEL_WARNING, NULL, __VA_ARGS__)
609 #define GST_INFO(...) GST_CAT_LEVEL_LOG (GST_CAT_DEFAULT, GST_LEVEL_INFO, NULL, __VA_ARGS__)
610 #define GST_DEBUG(...) GST_CAT_LEVEL_LOG (GST_CAT_DEFAULT, GST_LEVEL_DEBUG, NULL, __VA_ARGS__)
611 #define GST_LOG(...) GST_CAT_LEVEL_LOG (GST_CAT_DEFAULT, GST_LEVEL_LOG, NULL, __VA_ARGS__)
613 #else
614 #ifdef G_HAVE_GNUC_VARARGS
616 #define GST_CAT_ERROR_OBJECT(cat,obj,args...) GST_CAT_LEVEL_LOG (cat, GST_LEVEL_ERROR, obj, ##args )
617 #define GST_CAT_WARNING_OBJECT(cat,obj,args...) GST_CAT_LEVEL_LOG (cat, GST_LEVEL_WARNING, obj, ##args )
618 #define GST_CAT_INFO_OBJECT(cat,obj,args...) GST_CAT_LEVEL_LOG (cat, GST_LEVEL_INFO, obj, ##args )
619 #define GST_CAT_DEBUG_OBJECT(cat,obj,args...) GST_CAT_LEVEL_LOG (cat, GST_LEVEL_DEBUG, obj, ##args )
620 #define GST_CAT_LOG_OBJECT(cat,obj,args...) GST_CAT_LEVEL_LOG (cat, GST_LEVEL_LOG, obj, ##args )
622 #define GST_CAT_ERROR(cat,args...) GST_CAT_LEVEL_LOG (cat, GST_LEVEL_ERROR, NULL, ##args )
623 #define GST_CAT_WARNING(cat,args...) GST_CAT_LEVEL_LOG (cat, GST_LEVEL_WARNING, NULL, ##args )
624 #define GST_CAT_INFO(cat,args...) GST_CAT_LEVEL_LOG (cat, GST_LEVEL_INFO, NULL, ##args )
625 #define GST_CAT_DEBUG(cat,args...) GST_CAT_LEVEL_LOG (cat, GST_LEVEL_DEBUG, NULL, ##args )
626 #define GST_CAT_LOG(cat,args...) GST_CAT_LEVEL_LOG (cat, GST_LEVEL_LOG, NULL, ##args )
628 #define GST_ERROR_OBJECT(obj,args...) GST_CAT_LEVEL_LOG (GST_CAT_DEFAULT, GST_LEVEL_ERROR, obj, ##args )
629 #define GST_WARNING_OBJECT(obj,args...) GST_CAT_LEVEL_LOG (GST_CAT_DEFAULT, GST_LEVEL_WARNING, obj, ##args )
630 #define GST_INFO_OBJECT(obj,args...) GST_CAT_LEVEL_LOG (GST_CAT_DEFAULT, GST_LEVEL_INFO, obj, ##args )
631 #define GST_DEBUG_OBJECT(obj,args...) GST_CAT_LEVEL_LOG (GST_CAT_DEFAULT, GST_LEVEL_DEBUG, obj, ##args )
632 #define GST_LOG_OBJECT(obj,args...) GST_CAT_LEVEL_LOG (GST_CAT_DEFAULT, GST_LEVEL_LOG, obj, ##args )
634 #define GST_ERROR(args...) GST_CAT_LEVEL_LOG (GST_CAT_DEFAULT, GST_LEVEL_ERROR, NULL, ##args )
635 #define GST_WARNING(args...) GST_CAT_LEVEL_LOG (GST_CAT_DEFAULT, GST_LEVEL_WARNING, NULL, ##args )
636 #define GST_INFO(args...) GST_CAT_LEVEL_LOG (GST_CAT_DEFAULT, GST_LEVEL_INFO, NULL, ##args )
637 #define GST_DEBUG(args...) GST_CAT_LEVEL_LOG (GST_CAT_DEFAULT, GST_LEVEL_DEBUG, NULL, ##args )
638 #define GST_LOG(args...) GST_CAT_LEVEL_LOG (GST_CAT_DEFAULT, GST_LEVEL_LOG, NULL, ##args )
640 #else
641 /* no variadic macros, use inline */
642 static inline void
643 GST_CAT_ERROR_OBJECT (GstDebugCategory * cat, gpointer obj, const char *format,
644 ...)
645 {
646 va_list varargs;
648 va_start (varargs, format);
649 GST_CAT_LEVEL_LOG_valist (cat, GST_LEVEL_ERROR, obj, format, varargs);
650 va_end (varargs);
651 }
653 static inline void
654 GST_CAT_WARNING_OBJECT (GstDebugCategory * cat, gpointer obj,
655 const char *format, ...)
656 {
657 va_list varargs;
659 va_start (varargs, format);
660 GST_CAT_LEVEL_LOG_valist (cat, GST_LEVEL_WARNING, obj, format, varargs);
661 va_end (varargs);
662 }
664 static inline void
665 GST_CAT_INFO_OBJECT (GstDebugCategory * cat, gpointer obj, const char *format,
666 ...)
667 {
668 va_list varargs;
670 va_start (varargs, format);
671 GST_CAT_LEVEL_LOG_valist (cat, GST_LEVEL_INFO, obj, format, varargs);
672 va_end (varargs);
673 }
675 static inline void
676 GST_CAT_DEBUG_OBJECT (GstDebugCategory * cat, gpointer obj, const char *format,
677 ...)
678 {
679 va_list varargs;
681 va_start (varargs, format);
682 GST_CAT_LEVEL_LOG_valist (cat, GST_LEVEL_DEBUG, obj, format, varargs);
683 va_end (varargs);
684 }
686 static inline void
687 GST_CAT_LOG_OBJECT (GstDebugCategory * cat, gpointer obj, const char *format,
688 ...)
689 {
690 va_list varargs;
692 va_start (varargs, format);
693 GST_CAT_LEVEL_LOG_valist (cat, GST_LEVEL_LOG, obj, format, varargs);
694 va_end (varargs);
695 }
697 static inline void
698 GST_CAT_ERROR (GstDebugCategory * cat, const char *format, ...)
699 {
700 va_list varargs;
702 va_start (varargs, format);
703 GST_CAT_LEVEL_LOG_valist (cat, GST_LEVEL_ERROR, NULL, format, varargs);
704 va_end (varargs);
705 }
707 static inline void
708 GST_CAT_WARNING (GstDebugCategory * cat, const char *format, ...)
709 {
710 va_list varargs;
712 va_start (varargs, format);
713 GST_CAT_LEVEL_LOG_valist (cat, GST_LEVEL_WARNING, NULL, format, varargs);
714 va_end (varargs);
715 }
717 static inline void
718 GST_CAT_INFO (GstDebugCategory * cat, const char *format, ...)
719 {
720 va_list varargs;
722 va_start (varargs, format);
723 GST_CAT_LEVEL_LOG_valist (cat, GST_LEVEL_INFO, NULL, format, varargs);
724 va_end (varargs);
725 }
727 static inline void
728 GST_CAT_DEBUG (GstDebugCategory * cat, const char *format, ...)
729 {
730 va_list varargs;
732 va_start (varargs, format);
733 GST_CAT_LEVEL_LOG_valist (cat, GST_LEVEL_DEBUG, NULL, format, varargs);
734 va_end (varargs);
735 }
737 static inline void
738 GST_CAT_LOG (GstDebugCategory * cat, const char *format, ...)
739 {
740 va_list varargs;
742 va_start (varargs, format);
743 GST_CAT_LEVEL_LOG_valist (cat, GST_LEVEL_LOG, NULL, format, varargs);
744 va_end (varargs);
745 }
747 static inline void
748 GST_ERROR_OBJECT (gpointer obj, const char *format, ...)
749 {
750 va_list varargs;
752 va_start (varargs, format);
753 GST_CAT_LEVEL_LOG_valist (GST_CAT_DEFAULT, GST_LEVEL_ERROR, obj, format,
754 varargs);
755 va_end (varargs);
756 }
758 static inline void
759 GST_WARNING_OBJECT (gpointer obj, const char *format, ...)
760 {
761 va_list varargs;
763 va_start (varargs, format);
764 GST_CAT_LEVEL_LOG_valist (GST_CAT_DEFAULT, GST_LEVEL_WARNING, obj, format,
765 varargs);
766 va_end (varargs);
767 }
769 static inline void
770 GST_INFO_OBJECT (gpointer obj, const char *format, ...)
771 {
772 va_list varargs;
774 va_start (varargs, format);
775 GST_CAT_LEVEL_LOG_valist (GST_CAT_DEFAULT, GST_LEVEL_INFO, obj, format,
776 varargs);
777 va_end (varargs);
778 }
780 static inline void
781 GST_DEBUG_OBJECT (gpointer obj, const char *format, ...)
782 {
783 va_list varargs;
785 va_start (varargs, format);
786 GST_CAT_LEVEL_LOG_valist (GST_CAT_DEFAULT, GST_LEVEL_DEBUG, obj, format,
787 varargs);
788 va_end (varargs);
789 }
791 static inline void
792 GST_LOG_OBJECT (gpointer obj, const char *format, ...)
793 {
794 va_list varargs;
796 va_start (varargs, format);
797 GST_CAT_LEVEL_LOG_valist (GST_CAT_DEFAULT, GST_LEVEL_LOG, obj, format,
798 varargs);
799 va_end (varargs);
800 }
802 static inline void
803 GST_ERROR (const char *format, ...)
804 {
805 va_list varargs;
807 va_start (varargs, format);
808 GST_CAT_LEVEL_LOG_valist (GST_CAT_DEFAULT, GST_LEVEL_ERROR, NULL, format,
809 varargs);
810 va_end (varargs);
811 }
813 static inline void
814 GST_WARNING (const char *format, ...)
815 {
816 va_list varargs;
818 va_start (varargs, format);
819 GST_CAT_LEVEL_LOG_valist (GST_CAT_DEFAULT, GST_LEVEL_WARNING, NULL, format,
820 varargs);
821 va_end (varargs);
822 }
824 static inline void
825 GST_INFO (const char *format, ...)
826 {
827 va_list varargs;
829 va_start (varargs, format);
830 GST_CAT_LEVEL_LOG_valist (GST_CAT_DEFAULT, GST_LEVEL_INFO, NULL, format,
831 varargs);
832 va_end (varargs);
833 }
835 static inline void
836 GST_DEBUG (const char *format, ...)
837 {
838 va_list varargs;
840 va_start (varargs, format);
841 GST_CAT_LEVEL_LOG_valist (GST_CAT_DEFAULT, GST_LEVEL_DEBUG, NULL, format,
842 varargs);
843 va_end (varargs);
844 }
846 static inline void
847 GST_LOG (const char *format, ...)
848 {
849 va_list varargs;
851 va_start (varargs, format);
852 GST_CAT_LEVEL_LOG_valist (GST_CAT_DEFAULT, GST_LEVEL_LOG, NULL,
853 format, varargs);
854 va_end (varargs);
855 }
856 #endif
857 #endif
860 /********** function pointer stuff **********/
862 typedef void (* GstDebugFuncPtr) (void);
863 void _gst_debug_register_funcptr (GstDebugFuncPtr func,
864 gchar * ptrname);
865 G_CONST_RETURN gchar *
866 _gst_debug_nameof_funcptr (GstDebugFuncPtr func);
868 /**
869 * GST_DEBUG_FUNCPTR:
870 * @ptr: pointer to the function to register
871 *
872 * Register a pointer to a function with its name, so it can later be used by
873 * GST_DEBUG_FUNCPTR_NAME().
874 */
875 #define GST_DEBUG_FUNCPTR(ptr) \
876 (_gst_debug_register_funcptr((GstDebugFuncPtr)(ptr), #ptr) , ptr)
878 /**
879 * GST_DEBUG_FUNCPTR_NAME:
880 * @ptr: pointer to the function to look up the name
881 *
882 * Retrieves the name of the function, if it was previously registered with
883 * GST_DEBUG_FUNCPTR(). If not, it returns a description of the pointer.
884 *
885 * Make sure you free the string after use.
886 */
887 #define GST_DEBUG_FUNCPTR_NAME(ptr) \
888 _gst_debug_nameof_funcptr((GstDebugFuncPtr)ptr)
890 #else /* GST_DISABLE_GST_DEBUG */
892 #if defined(__GNUC__) && __GNUC__ >= 3
893 # pragma GCC poison gst_debug_log
894 # pragma GCC poison gst_debug_log_valist
895 # pragma GCC poison _gst_debug_category_new
896 #endif
898 #define _gst_debug_init() /* NOP */
900 #define gst_debug_set_default_threshold(level) /* NOP */
901 #define gst_debug_get_default_threshold() (GST_LEVEL_NONE)
903 #define gst_debug_level_get_name(level) ("NONE")
904 #define gst_debug_add_log_function(func,data) /* NOP */
905 guint gst_debug_remove_log_function (GstLogFunction func);
906 guint gst_debug_remove_log_function_by_data (gpointer data);
907 #define gst_debug_set_active(active) /* NOP */
908 #define gst_debug_is_active() (FALSE)
909 #define gst_debug_set_colored(colored) /* NOP */
910 #define gst_debug_is_colored() (FALSE)
911 #define gst_debug_set_default_threshold(level) /* NOP */
912 #define gst_debug_get_default_threshold() (GST_LEVEL_NONE)
913 #define gst_debug_set_threshold_for_name(name,level) /* NOP */
914 #define gst_debug_unset_threshold_for_name(name) /* NOP */
916 #define GST_DEBUG_CATEGORY(var) /* NOP */
917 #define GST_DEBUG_CATEGORY_EXTERN(var) /* NOP */
918 #if !defined(G_HAVE_GNUC_VARARGS) && !defined(G_HAVE_ISO_VARARGS)
919 #define GST_DEBUG_CATEGORY_STATIC(var) static GstDebugCategory *var = NULL
920 #else
921 #define GST_DEBUG_CATEGORY_STATIC(var) /* NOP */
922 #endif
923 #define GST_DEBUG_CATEGORY_INIT(var,name,color,desc) /* NOP */
924 #define gst_debug_category_free(category) /* NOP */
925 #define gst_debug_category_set_threshold(category,level) /* NOP */
926 #define gst_debug_category_reset_threshold(category) /* NOP */
927 #define gst_debug_category_get_threshold(category) (GST_LEVEL_NONE)
928 #define gst_debug_category_get_name(cat) ("")
929 #define gst_debug_category_get_color(cat) (0)
930 #define gst_debug_category_get_description(cat) ("")
931 #define gst_debug_get_all_categories() (NULL)
932 #define gst_debug_construct_term_color(colorinfo) (g_strdup ("00"))
934 #ifdef G_HAVE_ISO_VARARGS
936 #define GST_CAT_LEVEL_LOG(cat,level,...) /* NOP */
938 #define GST_CAT_ERROR_OBJECT(...) /* NOP */
939 #define GST_CAT_WARNING_OBJECT(...) /* NOP */
940 #define GST_CAT_INFO_OBJECT(...) /* NOP */
941 #define GST_CAT_DEBUG_OBJECT(...) /* NOP */
942 #define GST_CAT_LOG_OBJECT(...) /* NOP */
944 #define GST_CAT_ERROR(...) /* NOP */
945 #define GST_CAT_WARNING(...) /* NOP */
946 #define GST_CAT_INFO(...) /* NOP */
947 #define GST_CAT_DEBUG(...) /* NOP */
948 #define GST_CAT_LOG(...) /* NOP */
950 #define GST_ERROR_OBJECT(...) /* NOP */
951 #define GST_WARNING_OBJECT(...) /* NOP */
952 #define GST_INFO_OBJECT(...) /* NOP */
953 #define GST_DEBUG_OBJECT(...) /* NOP */
954 #define GST_LOG_OBJECT(...) /* NOP */
956 #define GST_ERROR(...) /* NOP */
957 #define GST_WARNING(...) /* NOP */
958 #define GST_INFO(...) /* NOP */
959 #define GST_DEBUG(...) /* NOP */
960 #define GST_LOG(...) /* NOP */
962 #else
963 #ifdef G_HAVE_GNUC_VARARGS
965 #define GST_CAT_LEVEL_LOG(cat,level,args...) /* NOP */
967 #define GST_CAT_ERROR_OBJECT(args...) /* NOP */
968 #define GST_CAT_WARNING_OBJECT(args...) /* NOP */
969 #define GST_CAT_INFO_OBJECT(args...) /* NOP */
970 #define GST_CAT_DEBUG_OBJECT(args...) /* NOP */
971 #define GST_CAT_LOG_OBJECT(args...) /* NOP */
973 #define GST_CAT_ERROR(args...) /* NOP */
974 #define GST_CAT_WARNING(args...) /* NOP */
975 #define GST_CAT_INFO(args...) /* NOP */
976 #define GST_CAT_DEBUG(args...) /* NOP */
977 #define GST_CAT_LOG(args...) /* NOP */
979 #define GST_ERROR_OBJECT(args...) /* NOP */
980 #define GST_WARNING_OBJECT(args...) /* NOP */
981 #define GST_INFO_OBJECT(args...) /* NOP */
982 #define GST_DEBUG_OBJECT(args...) /* NOP */
983 #define GST_LOG_OBJECT(args...) /* NOP */
985 #define GST_ERROR(args...) /* NOP */
986 #define GST_WARNING(args...) /* NOP */
987 #define GST_INFO(args...) /* NOP */
988 #define GST_DEBUG(args...) /* NOP */
989 #define GST_LOG(args...) /* NOP */
991 #else
992 static inline void
993 GST_CAT_LEVEL_LOG_valist (GstDebugCategory * cat,
994 GstDebugLevel level, gpointer object, const char *format, va_list varargs)
995 {
996 }
998 static inline void
999 GST_CAT_ERROR_OBJECT (GstDebugCategory * cat, gpointer obj, const char *format,
1000 ...)
1001 {
1002 }
1004 static inline void
1005 GST_CAT_WARNING_OBJECT (GstDebugCategory * cat, gpointer obj,
1006 const char *format, ...)
1007 {
1008 }
1010 static inline void
1011 GST_CAT_INFO_OBJECT (GstDebugCategory * cat, gpointer obj, const char *format,
1012 ...)
1013 {
1014 }
1016 static inline void
1017 GST_CAT_DEBUG_OBJECT (GstDebugCategory * cat, gpointer obj, const char *format,
1018 ...)
1019 {
1020 }
1022 static inline void
1023 GST_CAT_LOG_OBJECT (GstDebugCategory * cat, gpointer obj, const char *format,
1024 ...)
1025 {
1026 }
1028 static inline void
1029 GST_CAT_ERROR (GstDebugCategory * cat, const char *format, ...)
1030 {
1031 }
1033 static inline void
1034 GST_CAT_WARNING (GstDebugCategory * cat, const char *format, ...)
1035 {
1036 }
1038 static inline void
1039 GST_CAT_INFO (GstDebugCategory * cat, const char *format, ...)
1040 {
1041 }
1043 static inline void
1044 GST_CAT_DEBUG (GstDebugCategory * cat, const char *format, ...)
1045 {
1046 }
1048 static inline void
1049 GST_CAT_LOG (GstDebugCategory * cat, const char *format, ...)
1050 {
1051 }
1053 static inline void
1054 GST_ERROR_OBJECT (gpointer obj, const char *format, ...)
1055 {
1056 }
1058 static inline void
1059 GST_WARNING_OBJECT (gpointer obj, const char *format, ...)
1060 {
1061 }
1063 static inline void
1064 GST_INFO_OBJECT (gpointer obj, const char *format, ...)
1065 {
1066 }
1068 static inline void
1069 GST_DEBUG_OBJECT (gpointer obj, const char *format, ...)
1070 {
1071 }
1073 static inline void
1074 GST_LOG_OBJECT (gpointer obj, const char *format, ...)
1075 {
1076 }
1078 static inline void
1079 GST_ERROR (const char *format, ...)
1080 {
1081 }
1083 static inline void
1084 GST_WARNING (const char *format, ...)
1085 {
1086 }
1088 static inline void
1089 GST_INFO (const char *format, ...)
1090 {
1091 }
1093 static inline void
1094 GST_DEBUG (const char *format, ...)
1095 {
1096 }
1098 static inline void
1099 GST_LOG (const char *format, ...)
1100 {
1101 }
1102 #endif
1103 #endif
1105 #define GST_DEBUG_FUNCPTR(ptr) (ptr)
1106 #define GST_DEBUG_FUNCPTR_NAME(ptr) (g_strdup_printf ("%p", ptr))
1108 #endif /* GST_DISABLE_GST_DEBUG */
1110 void gst_debug_print_stack_trace (void);
1112 G_END_DECLS
1114 #endif /* __GSTINFO_H__ */