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