info: rename new log macros from GST_*_OBJECT_ID -> GST_*_ID
[platform/upstream/gstreamer.git] / subprojects / gstreamer / gst / gstinfo.h
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., 51 Franklin St, Fifth Floor,
21  * Boston, MA 02110-1301, USA.
22  */
23
24 #ifndef __GSTINFO_H__
25 #define __GSTINFO_H__
26
27 #include <glib.h>
28 #include <glib-object.h>
29 #include <gst/gstconfig.h>
30
31 G_BEGIN_DECLS
32
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 occurred
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_error.
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_FIXME: Fixme messages are messages that indicate that something
46  *  in the executed code path is not fully implemented or handled yet. Note
47  *  that this does not replace proper error handling in any way, the purpose
48  *  of this message is to make it easier to spot incomplete/unfinished pieces
49  *  of code when reading the debug log.
50  * @GST_LEVEL_INFO: Informational messages should be used to keep the developer
51  *  updated about what is happening.
52  *  Examples where this should be used are when a typefind function has
53  *  successfully determined the type of the stream or when an mp3 plugin detects
54  *  the format to be used. ("This file has mono sound.")
55  * @GST_LEVEL_DEBUG: Debugging messages should be used when something common
56  *  happens that is not the expected default behavior, or something that's
57  *  useful to know but doesn't happen all the time (ie. per loop iteration or
58  *  buffer processed or event handled).
59  *  An example would be notifications about state changes or receiving/sending
60  *  of events.
61  * @GST_LEVEL_LOG: Log messages are messages that are very common but might be
62  *  useful to know. As a rule of thumb a pipeline that is running as expected
63  *  should never output anything else but LOG messages whilst processing data.
64  *  Use this log level to log recurring information in chain functions and
65  *  loop functions, for example.
66  * @GST_LEVEL_TRACE: Tracing-related messages.
67  *  Examples for this are referencing/dereferencing of objects.
68  * @GST_LEVEL_MEMDUMP: memory dump messages are used to log (small) chunks of
69  *  data as memory dumps in the log. They will be displayed as hexdump with
70  *  ASCII characters.
71  * @GST_LEVEL_COUNT: The number of defined debugging levels.
72  *
73  * The level defines the importance of a debugging message. The more important a
74  * message is, the greater the probability that the debugging system outputs it.
75  */
76 typedef enum {
77   GST_LEVEL_NONE = 0,
78   GST_LEVEL_ERROR = 1,
79   GST_LEVEL_WARNING = 2,
80   GST_LEVEL_FIXME = 3,
81   GST_LEVEL_INFO = 4,
82   GST_LEVEL_DEBUG = 5,
83   GST_LEVEL_LOG = 6,
84   GST_LEVEL_TRACE = 7,
85   /* add more */
86   GST_LEVEL_MEMDUMP = 9,
87   /* add more */
88   GST_LEVEL_COUNT
89 } GstDebugLevel;
90
91 /**
92  * GST_LEVEL_DEFAULT:
93  *
94  * Defines the default debugging level to be used with GStreamer. It is normally
95  * set to #GST_LEVEL_NONE so nothing get printed.
96  * As it can be configured at compile time, developer builds may chose to
97  * override that though.
98  * You can use this as an argument to gst_debug_set_default_threshold() to
99  * reset the debugging output to default behaviour.
100  */
101 #ifndef GST_LEVEL_DEFAULT
102 #define GST_LEVEL_DEFAULT GST_LEVEL_NONE
103 #endif
104
105 /**
106  * GST_LEVEL_MAX:
107  *
108  * Defines the maximum debugging level to be enabled at compilation time. By default
109  * it is set such that all debugging statements will be enabled.
110  *
111  * If you wish to compile GStreamer and plugins with only some debugging statements
112  * (Such as just warnings and errors), you can define it at compile time to the
113  * maximum debug level. Any debug statements above that level will be compiled out.
114  *
115  * Since: 1.6
116  */
117 #ifndef GST_LEVEL_MAX
118 #define GST_LEVEL_MAX GST_LEVEL_COUNT
119 #endif
120
121 /* defines for format (colors etc)
122  * don't change them around, it uses terminal layout
123  * Terminal color strings:
124  * 00=none 01=bold 04=underscore 05=blink 07=reverse 08=concealed
125  * Text color codes:
126  * 30=black 31=red 32=green 33=yellow 34=blue 35=magenta 36=cyan 37=white
127  * Background color codes:
128  * 40=black 41=red 42=green 43=yellow 44=blue 45=magenta 46=cyan 47=white
129  */
130 /**
131  * GstDebugColorFlags:
132  * @GST_DEBUG_FG_BLACK: Use black as foreground color.
133  * @GST_DEBUG_FG_RED: Use red as foreground color.
134  * @GST_DEBUG_FG_GREEN: Use green as foreground color.
135  * @GST_DEBUG_FG_YELLOW: Use yellow as foreground color.
136  * @GST_DEBUG_FG_BLUE: Use blue as foreground color.
137  * @GST_DEBUG_FG_MAGENTA: Use magenta as foreground color.
138  * @GST_DEBUG_FG_CYAN: Use cyan as foreground color.
139  * @GST_DEBUG_FG_WHITE: Use white as foreground color.
140  * @GST_DEBUG_BG_BLACK: Use black as background color.
141  * @GST_DEBUG_BG_RED: Use red as background color.
142  * @GST_DEBUG_BG_GREEN: Use green as background color.
143  * @GST_DEBUG_BG_YELLOW: Use yellow as background color.
144  * @GST_DEBUG_BG_BLUE: Use blue as background color.
145  * @GST_DEBUG_BG_MAGENTA: Use magenta as background color.
146  * @GST_DEBUG_BG_CYAN: Use cyan as background color.
147  * @GST_DEBUG_BG_WHITE: Use white as background color.
148  * @GST_DEBUG_BOLD: Make the output bold.
149  * @GST_DEBUG_UNDERLINE: Underline the output.
150  *
151  * These are some terminal style flags you can use when creating your
152  * debugging categories to make them stand out in debugging output.
153  */
154 typedef enum { /*< flags >*/
155   /* colors */
156   GST_DEBUG_FG_BLACK            = 0x0000,
157   GST_DEBUG_FG_RED              = 0x0001,
158   GST_DEBUG_FG_GREEN            = 0x0002,
159   GST_DEBUG_FG_YELLOW           = 0x0003,
160   GST_DEBUG_FG_BLUE             = 0x0004,
161   GST_DEBUG_FG_MAGENTA          = 0x0005,
162   GST_DEBUG_FG_CYAN             = 0x0006,
163   GST_DEBUG_FG_WHITE            = 0x0007,
164   /* background colors */
165   GST_DEBUG_BG_BLACK            = 0x0000,
166   GST_DEBUG_BG_RED              = 0x0010,
167   GST_DEBUG_BG_GREEN            = 0x0020,
168   GST_DEBUG_BG_YELLOW           = 0x0030,
169   GST_DEBUG_BG_BLUE             = 0x0040,
170   GST_DEBUG_BG_MAGENTA          = 0x0050,
171   GST_DEBUG_BG_CYAN             = 0x0060,
172   GST_DEBUG_BG_WHITE            = 0x0070,
173   /* other formats */
174   GST_DEBUG_BOLD                = 0x0100,
175   GST_DEBUG_UNDERLINE           = 0x0200
176 } GstDebugColorFlags;
177
178 /**
179  * GstStackTraceFlags:
180  * @GST_STACK_TRACE_SHOW_NONE: Try to retrieve the minimum information
181  *                             available, which may be none on some platforms
182  *                             (Since: 1.18)
183  * @GST_STACK_TRACE_SHOW_FULL: Try to retrieve as much information as possible,
184  *                             including source information when getting the
185  *                             stack trace
186  *
187  * Since: 1.12
188  */
189 typedef enum {
190     GST_STACK_TRACE_SHOW_NONE = 0,
191     GST_STACK_TRACE_SHOW_FULL = 1 << 0
192 } GstStackTraceFlags;
193
194 /**
195  * GstDebugColorMode:
196  * @GST_DEBUG_COLOR_MODE_OFF: Do not use colors in logs.
197  * @GST_DEBUG_COLOR_MODE_ON: Paint logs in a platform-specific way.
198  * @GST_DEBUG_COLOR_MODE_UNIX: Paint logs with UNIX terminal color codes
199  *                             no matter what platform GStreamer is running on.
200  */
201 typedef enum {
202   GST_DEBUG_COLOR_MODE_OFF  = 0,
203   GST_DEBUG_COLOR_MODE_ON   = 1,
204   GST_DEBUG_COLOR_MODE_UNIX = 2
205 } GstDebugColorMode;
206
207
208 #define GST_DEBUG_FG_MASK       (0x000F)
209 #define GST_DEBUG_BG_MASK       (0x00F0)
210 #define GST_DEBUG_FORMAT_MASK   (0xFF00)
211
212 typedef struct _GstDebugCategory GstDebugCategory;
213 /**
214  * GstDebugCategory:
215  *
216  * This is the struct that describes the categories. Once initialized with
217  * #GST_DEBUG_CATEGORY_INIT, its values can't be changed anymore.
218  */
219 struct _GstDebugCategory {
220   /*< private >*/
221   gint                  threshold;
222   guint                 color;          /* see defines above */
223
224   const gchar *         name;
225   const gchar *         description;
226 };
227
228 /********** some convenience macros for debugging **********/
229
230 /**
231  * GST_STR_NULL:
232  * @str: (allow-none): The string to check.
233  *
234  * Macro to use when a string must not be %NULL, but may be %NULL. If the string
235  * is %NULL, "(NULL)" is printed instead.
236  * In GStreamer printf string arguments may not be %NULL, because on some
237  * platforms (ie Solaris) the libc crashes in that case. This includes debugging
238  * strings.
239  */
240 #define GST_STR_NULL(str) ((str) ? (str) : "(NULL)")
241
242 /* FIXME, not MT safe */
243 /**
244  * GST_DEBUG_PAD_NAME:
245  * @pad: The pad to debug.
246  *
247  * Evaluates to 2 strings, that describe the pad. Often used in debugging
248  * statements.
249  */
250 #define GST_DEBUG_PAD_NAME(pad) \
251   (pad != NULL) ?  \
252   ((GST_OBJECT_PARENT(pad) != NULL) ? \
253   GST_STR_NULL (GST_OBJECT_NAME (GST_OBJECT_PARENT(pad))) : \
254   "''" ) : "''", \
255   (pad != NULL) ? GST_STR_NULL (GST_OBJECT_NAME (pad)) : "''"
256
257 /**
258  * GST_FUNCTION:
259  *
260  * This macro should evaluate to the name of the current function and be should
261  * be defined when configuring your project, as it is compiler dependent. If it
262  * is not defined, some default value is used. It is used to provide debugging
263  * output with the function name of the message.
264  *
265  * Note that this is different from G_STRFUNC as we do not want the full
266  * function signature in C++ code.
267  */
268 #ifndef GST_FUNCTION
269 #if defined (__STDC__) && defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
270 #  define GST_FUNCTION     ((const char*) (__func__))
271 #elif defined (__GNUC__) || (defined (_MSC_VER) && _MSC_VER >= 1300)
272 #  define GST_FUNCTION     ((const char*) (__FUNCTION__))
273 #else
274 #  define GST_FUNCTION     ((const char*) ("???"))
275 #endif
276 #endif /* ifndef GST_FUNCTION */
277
278 /**
279  * GST_PTR_FORMAT: (skip):
280  *
281  * printf format type used to debug GStreamer types. You can use this in
282  * combination with GStreamer's debug logging system as well as the functions
283  * gst_info_vasprintf(), gst_info_strdup_vprintf() and gst_info_strdup_printf()
284  * to pretty-print the following types: #GstCaps, #GstStructure,
285  * #GstCapsFeatures, #GstTagList, #GstDateTime, #GstBuffer, #GstBufferList,
286  * #GstMessage, #GstEvent, #GstQuery, #GstContext, #GstPad, #GstObject. All
287  * #GObject types will be printed as typename plus pointer, and everything
288  * else will simply be printed as pointer address.
289  *
290  * This can only be used on types whose size is >= sizeof(gpointer).
291  */
292 #define GST_PTR_FORMAT     "p\aA"
293
294 /**
295  * GST_SEGMENT_FORMAT: (skip):
296  *
297  * printf format type used to debug GStreamer segments. You can use this in
298  * combination with GStreamer's debug logging system as well as the functions
299  * gst_info_vasprintf(), gst_info_strdup_vprintf() and gst_info_strdup_printf()
300  * to pretty-print #GstSegment structures.
301  * This can only be used on pointers to GstSegment structures.
302  */
303 #define GST_SEGMENT_FORMAT "p\aB"
304
305 /**
306  * GST_TIMEP_FORMAT: (skip):
307  *
308  * printf format type used to debug GStreamer ClockTime pointers. You can use
309  * this in combination with GStreamer's debug logging system as well as the
310  * functions gst_info_vasprintf(), gst_info_strdup_vprintf() and
311  * gst_info_strdup_printf() to pretty-print #GstClockTime pointers. This can
312  * only be used on pointers to GstClockTime values.
313  *
314  * Since: 1.18
315  */
316 #define GST_TIMEP_FORMAT "p\aT"
317
318 /**
319  * GST_STIMEP_FORMAT: (skip):
320  *
321  * printf format type used to debug GStreamer signed time value pointers. You
322  * can use this in combination with GStreamer's debug logging system as well as
323  * the functions gst_info_vasprintf(), gst_info_strdup_vprintf() and
324  * gst_info_strdup_printf() to pretty-print signed time (pointers to
325  * #GstClockTimeDiff or #gint64).
326  *
327  * Since: 1.18
328  */
329 #define GST_STIMEP_FORMAT "p\aS"
330
331 typedef struct _GstDebugMessage GstDebugMessage;
332
333 /**
334  * GstLogFunction:
335  * @category: a #GstDebugCategory
336  * @level: a #GstDebugLevel
337  * @file: file name
338  * @function: function name
339  * @line: line number
340  * @object: a #GObject
341  * @message: the message
342  * @user_data: user data for the log function
343  *
344  * Function prototype for a logging function that can be registered with
345  * gst_debug_add_log_function().
346  * Use G_GNUC_NO_INSTRUMENT on that function.
347  */
348 typedef void (*GstLogFunction)  (GstDebugCategory * category,
349                                  GstDebugLevel      level,
350                                  const gchar      * file,
351                                  const gchar      * function,
352                                  gint               line,
353                                  GObject          * object,
354                                  GstDebugMessage  * message,
355                                  gpointer           user_data);
356
357 GST_API
358 void                gst_debug_log            (GstDebugCategory * category,
359                                           GstDebugLevel      level,
360                                           const gchar      * file,
361                                           const gchar      * function,
362                                           gint               line,
363                                           GObject          * object,
364                                           const gchar      * format,
365                                           ...) G_GNUC_PRINTF (7, 8) G_GNUC_NO_INSTRUMENT;
366 GST_API
367 void            gst_debug_log_valist     (GstDebugCategory * category,
368                                           GstDebugLevel      level,
369                                           const gchar      * file,
370                                           const gchar      * function,
371                                           gint               line,
372                                           GObject          * object,
373                                           const gchar      * format,
374                                           va_list            args) G_GNUC_NO_INSTRUMENT;
375
376 GST_API
377 void            gst_debug_log_literal    (GstDebugCategory * category,
378                                           GstDebugLevel      level,
379                                           const gchar      * file,
380                                           const gchar      * function,
381                                           gint               line,
382                                           GObject          * object,
383                                           const gchar      * message_string) G_GNUC_NO_INSTRUMENT;
384
385 GST_API
386 void            gst_debug_log_id          (GstDebugCategory * category,
387                                           GstDebugLevel      level,
388                                           const gchar      * file,
389                                           const gchar      * function,
390                                           gint               line,
391                                           const gchar      * id,
392                                           const gchar      * format,
393                                           ...) G_GNUC_PRINTF (7, 8) G_GNUC_NO_INSTRUMENT;
394 GST_API
395 void            gst_debug_log_id_valist  (GstDebugCategory * category,
396                                           GstDebugLevel      level,
397                                           const gchar      * file,
398                                           const gchar      * function,
399                                           gint               line,
400                                           const gchar      * id,
401                                           const gchar      * format,
402                                           va_list            args) G_GNUC_NO_INSTRUMENT;
403
404 GST_API
405 void            gst_debug_log_id_literal (GstDebugCategory * category,
406                                           GstDebugLevel      level,
407                                           const gchar      * file,
408                                           const gchar      * function,
409                                           gint               line,
410                                           const gchar      * id,
411                                           const gchar      * message_string) G_GNUC_NO_INSTRUMENT;
412
413 /* do not use this function, use the GST_DEBUG_CATEGORY_INIT macro */
414
415 GST_API
416 GstDebugCategory *_gst_debug_category_new (const gchar * name,
417                                            guint         color,
418                                            const gchar * description);
419
420 /* do not use this function, use the GST_DEBUG_CATEGORY_GET macro */
421
422 GST_API
423 GstDebugCategory *_gst_debug_get_category (const gchar *name);
424
425
426 /* do not use these functions, use the GST_CAT_MEMDUMP_* macros */
427
428 GST_API
429 void _gst_debug_dump_mem (GstDebugCategory * cat, const gchar * file,
430     const gchar * func, gint line, GObject * obj, const gchar * msg,
431     const guint8 * data, guint length);
432
433 GST_API
434 void _gst_debug_dump_mem_id (GstDebugCategory * cat, const gchar * file,
435     const gchar * func, gint line, const gchar *object_id, const gchar * msg,
436     const guint8 * data, guint length);
437
438 /**
439  * GstDebugFuncPtr: (attributes doc.skip=true)
440  * we define this to avoid a compiler warning regarding a cast from a function
441  * pointer to a void pointer
442  * (see https://bugzilla.gnome.org/show_bug.cgi?id=309253)
443  */
444 typedef void (* GstDebugFuncPtr)        (void);
445
446 /* do no use these functions, use the GST_DEBUG*_FUNCPTR macros */
447
448 GST_API
449 void    _gst_debug_register_funcptr     (GstDebugFuncPtr        func,
450                                          const gchar *          ptrname);
451 GST_API
452 const gchar *
453         _gst_debug_nameof_funcptr       (GstDebugFuncPtr        func) G_GNUC_NO_INSTRUMENT;
454
455
456 GST_API
457 const gchar   * gst_debug_message_get    (GstDebugMessage  * message);
458
459 GST_API
460 const gchar   * gst_debug_message_get_id (GstDebugMessage  * message);
461
462 GST_API
463 gchar         * gst_debug_log_get_line    (GstDebugCategory * category,
464                                            GstDebugLevel      level,
465                                            const gchar      * file,
466                                            const gchar      * function,
467                                            gint               line,
468                                            GObject          * object,
469                                            GstDebugMessage  * message) G_GNUC_NO_INSTRUMENT;
470
471 GST_API
472 void            gst_debug_log_default    (GstDebugCategory * category,
473                                           GstDebugLevel      level,
474                                           const gchar      * file,
475                                           const gchar      * function,
476                                           gint               line,
477                                           GObject          * object,
478                                           GstDebugMessage  * message,
479                                           gpointer           user_data) G_GNUC_NO_INSTRUMENT;
480
481 GST_API
482 const gchar *   gst_debug_level_get_name (GstDebugLevel level);
483
484 GST_API
485 void            gst_debug_add_log_function            (GstLogFunction func,
486                                                        gpointer       user_data,
487                                                        GDestroyNotify notify);
488 GST_API
489 guint           gst_debug_remove_log_function         (GstLogFunction func);
490
491 GST_API
492 guint           gst_debug_remove_log_function_by_data (gpointer       data);
493
494 GST_API
495 void            gst_debug_set_active  (gboolean active);
496
497 GST_API
498 gboolean        gst_debug_is_active   (void);
499
500 GST_API
501 void            gst_debug_set_colored (gboolean colored);
502
503 GST_API
504 void            gst_debug_set_color_mode   (GstDebugColorMode mode);
505
506 GST_API
507 void            gst_debug_set_color_mode_from_string (const gchar * mode);
508
509 GST_API
510 gboolean        gst_debug_is_colored  (void);
511
512 GST_API
513 GstDebugColorMode gst_debug_get_color_mode (void);
514
515 GST_API
516 void            gst_debug_set_default_threshold      (GstDebugLevel level);
517
518 GST_API
519 GstDebugLevel   gst_debug_get_default_threshold      (void);
520
521 GST_API
522 void            gst_debug_set_threshold_for_name     (const gchar * name,
523                                                       GstDebugLevel level);
524 GST_API
525 void            gst_debug_set_threshold_from_string  (const gchar * list, gboolean reset);
526
527 GST_API
528 void            gst_debug_unset_threshold_for_name   (const gchar * name);
529
530 GST_DEPRECATED
531 void            gst_debug_category_free              (GstDebugCategory *        category);
532
533 GST_API
534 void            gst_debug_category_set_threshold     (GstDebugCategory *        category,
535                                                       GstDebugLevel             level);
536
537 GST_API
538 void            gst_debug_category_reset_threshold   (GstDebugCategory *        category);
539
540 GST_API
541 GstDebugLevel   gst_debug_category_get_threshold     (GstDebugCategory *        category);
542
543 GST_API
544 const gchar *   gst_debug_category_get_name          (GstDebugCategory *        category);
545
546 GST_API
547 guint           gst_debug_category_get_color         (GstDebugCategory *        category);
548
549 GST_API
550 const gchar *   gst_debug_category_get_description   (GstDebugCategory *        category);
551
552 GST_API
553 GSList *        gst_debug_get_all_categories    (void);
554
555
556 GST_API
557 gchar * gst_debug_construct_term_color (guint colorinfo);
558
559 GST_API
560 gint    gst_debug_construct_win_color  (guint colorinfo);
561
562 GST_API
563 gint    gst_info_vasprintf              (gchar ** result,
564                                          const gchar * format,
565                                          va_list args) G_GNUC_PRINTF (2, 0);
566 GST_API
567 gchar * gst_info_strdup_vprintf         (const gchar *format, va_list args) G_GNUC_PRINTF (1, 0);
568
569 GST_API
570 gchar * gst_info_strdup_printf          (const gchar *format, ...) G_GNUC_PRINTF (1, 2);
571
572 GST_API
573 void    gst_print                       (const gchar * format, ...) G_GNUC_PRINTF (1, 2);
574
575 GST_API
576 void    gst_println                     (const gchar * format, ...) G_GNUC_PRINTF (1, 2);
577
578 GST_API
579 void    gst_printerr                    (const gchar * format, ...) G_GNUC_PRINTF (1, 2);
580
581 GST_API
582 void    gst_printerrln                  (const gchar * format, ...) G_GNUC_PRINTF (1, 2);
583
584 #ifndef GST_DISABLE_GST_DEBUG
585
586 /* cast to void * avoids a warning with gcc 6
587  * see https://bugzilla.gnome.org/show_bug.cgi?id=764526 */
588 #define gst_debug_add_log_function(func,data,notify) \
589 G_STMT_START{                                        \
590   if ((func) == (void *) gst_debug_log_default) {    \
591     gst_debug_add_log_function(NULL,data,notify);    \
592   } else {                                           \
593     gst_debug_add_log_function(func,data,notify);    \
594   }                                                  \
595 }G_STMT_END
596
597 #define gst_debug_remove_log_function(func)          \
598     ((func) == (void *) gst_debug_log_default) ?     \
599         gst_debug_remove_log_function(NULL) :        \
600         gst_debug_remove_log_function(func)
601
602 /**
603  * GST_DEBUG_CATEGORY:
604  * @cat: the category
605  *
606  * Defines a GstDebugCategory variable.
607  * This macro expands to nothing if debugging is disabled.
608  */
609 #define GST_DEBUG_CATEGORY(cat) GstDebugCategory *cat = NULL
610 /**
611  * GST_DEBUG_CATEGORY_EXTERN:
612  * @cat: the category
613  *
614  * Declares a GstDebugCategory variable as extern. Use in header files.
615  * This macro expands to nothing if debugging is disabled.
616  */
617 #define GST_DEBUG_CATEGORY_EXTERN(cat) extern GstDebugCategory *cat
618
619 /**
620  * GST_DEBUG_CATEGORY_STATIC:
621  * @cat: the category
622  *
623  * Defines a static GstDebugCategory variable.
624  * This macro expands to nothing if debugging is disabled.
625  */
626 #define GST_DEBUG_CATEGORY_STATIC(cat) static GstDebugCategory *cat = NULL
627
628 /**
629  * GST_DEBUG_CATEGORY_INIT:
630  * @cat: the category to initialize.
631  * @name: the name of the category.
632  * @color: the colors to use for a color representation or 0 for no color.
633  * @description: optional description of the category.
634  *
635  * Initializes a new #GstDebugCategory with the given properties and set to
636  * the default threshold.
637  *
638  * > This macro expands to nothing if debugging is disabled.
639  * >
640  * > When naming your category, please follow the following conventions to ensure
641  * > that the pattern matching for categories works as expected. It is not
642  * > earth-shattering if you don't follow these conventions, but it would be nice
643  * > for everyone.
644  * >
645  * > If you define a category for a plugin or a feature of it, name the category
646  * > like the feature. So if you wanted to write a "filesrc" element, you would
647  * > name the category "filesrc". Use lowercase letters only.
648  * > If you define more than one category for the same element, append an
649  * > underscore and an identifier to your categories, like this: "filesrc_cache"
650  * >
651  * > If you create a library or an application using debugging categories, use a
652  * > common prefix followed by an underscore for all your categories. GStreamer
653  * > uses the GST prefix so GStreamer categories look like "GST_STATES". Be sure
654  * > to include uppercase letters.
655  *
656  */
657 #define GST_DEBUG_CATEGORY_INIT(cat,name,color,description) G_STMT_START{\
658   if (cat == NULL)                                                      \
659     cat = _gst_debug_category_new (name,color,description);             \
660 }G_STMT_END
661
662 /**
663  * GST_DEBUG_CATEGORY_GET:
664  * @cat: the category to initialize.
665  * @name: log category name
666  *
667  * Looks up an existing #GstDebugCategory by its @name and sets @cat. If the
668  * category is not found, but GST_CAT_DEFAULT is defined, that is assigned to
669  * @cat. Otherwise @cat will be %NULL.
670  *
671  * |[<!-- language="C" -->
672  * GST_DEBUG_CATEGORY_STATIC (gst_myplugin_debug);
673  * #define GST_CAT_DEFAULT gst_myplugin_debug
674  * GST_DEBUG_CATEGORY_STATIC (GST_CAT_PERFORMANCE);
675  * ...
676  * GST_DEBUG_CATEGORY_INIT (gst_myplugin_debug, "myplugin", 0, "nice element");
677  * GST_DEBUG_CATEGORY_GET (GST_CAT_PERFORMANCE, "GST_PERFORMANCE");
678  * ]|
679  */
680 #ifdef GST_CAT_DEFAULT
681 #define GST_DEBUG_CATEGORY_GET(cat,name)  G_STMT_START{\
682   cat = _gst_debug_get_category (name);                 \
683   if (!cat) {                                           \
684     cat = GST_CAT_DEFAULT;                              \
685   }                                                     \
686 }G_STMT_END
687 #else
688 #define GST_DEBUG_CATEGORY_GET(cat,name)  G_STMT_START{\
689   cat = _gst_debug_get_category (name);                 \
690 }G_STMT_END
691 #endif
692
693 /**
694  * GST_CAT_DEFAULT:
695  *
696  * Default gstreamer core debug log category. Please define your own.
697  */
698
699 GST_API GstDebugCategory *      GST_CAT_DEFAULT;
700 /* this symbol may not be used */
701
702 GST_API gboolean                 _gst_debug_enabled;
703
704 /* the min debug level, used for quickly discarding debug
705  * messages that fall under the threshold. */
706
707 GST_API GstDebugLevel            _gst_debug_min;
708
709 /**
710  * GST_CAT_LEVEL_LOG:
711  * @cat: category to use
712  * @level: the severity of the message
713  * @object: (allow-none): the #GObject the message belongs to or %NULL if none
714  * @...: A printf-style message to output
715  *
716  * Outputs a debugging message. This is the most general macro for outputting
717  * debugging messages. You will probably want to use one of the ones described
718  * below.
719  *
720  * There is no need to finish the end of the debug message with a newline
721  * character, a newline character will be added automatically.
722  */
723 #ifdef G_HAVE_ISO_VARARGS
724 #define GST_CAT_LEVEL_LOG(cat,level,object,...) G_STMT_START{           \
725   if (G_UNLIKELY ((level) <= GST_LEVEL_MAX && (level) <= _gst_debug_min)) {                                             \
726     gst_debug_log ((cat), (level), __FILE__, GST_FUNCTION, __LINE__,    \
727         (GObject *) (object), __VA_ARGS__);                             \
728   }                                                                     \
729 }G_STMT_END
730 #else /* G_HAVE_GNUC_VARARGS */
731 #ifdef G_HAVE_GNUC_VARARGS
732 #define GST_CAT_LEVEL_LOG(cat,level,object,args...) G_STMT_START{       \
733   if (G_UNLIKELY ((level) <= GST_LEVEL_MAX && (level) <= _gst_debug_min)) {                                             \
734     gst_debug_log ((cat), (level), __FILE__, GST_FUNCTION, __LINE__,    \
735         (GObject *) (object), ##args );                                 \
736   }                                                                     \
737 }G_STMT_END
738 #else /* no variadic macros, use inline */
739 static inline void
740 GST_CAT_LEVEL_LOG_valist (GstDebugCategory * cat,
741     GstDebugLevel level, gpointer object, const char *format, va_list varargs)
742 {
743   if (G_UNLIKELY ((level) <= GST_LEVEL_MAX && (level) <= _gst_debug_min)) {
744     gst_debug_log_valist (cat, level, "", "", 0, (GObject *) object, format,
745         varargs);
746   }
747 }
748
749 static inline void
750 GST_CAT_LEVEL_LOG (GstDebugCategory * cat, GstDebugLevel level,
751     gpointer object, const char *format, ...)
752 {
753   va_list varargs;
754
755   va_start (varargs, format);
756   GST_CAT_LEVEL_LOG_valist (cat, level, object, format, varargs);
757   va_end (varargs);
758 }
759 #endif
760 #endif /* G_HAVE_ISO_VARARGS */
761
762 /**
763  * GST_CAT_LEVEL_LOG_ID:
764  * @cat: category to use
765  * @level: the severity of the message
766  * @id: (transfer none) (allow-none): the identifier of the object this message
767  *     relates to, or %NULL if none
768  * @...: A printf-style message to output
769  *
770  * Outputs a debugging message. This is the most general macro for outputting
771  * debugging messages. You will probably want to use one of the ones described
772  * below.
773  *
774  * There is no need to finish the end of the debug message with a newline
775  * character, a newline character will be added automatically.
776  *
777  * Since: 1.22
778  */
779 #ifdef G_HAVE_ISO_VARARGS
780 #define GST_CAT_LEVEL_LOG_ID(cat,level,id,...) G_STMT_START{            \
781   if (G_UNLIKELY ((level) <= GST_LEVEL_MAX && (level) <= _gst_debug_min)) {                                             \
782     gst_debug_log_id ((cat), (level), __FILE__, GST_FUNCTION, __LINE__, \
783                       (id), __VA_ARGS__);                               \
784   }                                                                     \
785 }G_STMT_END
786 #else /* G_HAVE_GNUC_VARARGS */
787 #ifdef G_HAVE_GNUC_VARARGS
788 #define GST_CAT_LEVEL_LOG_ID(cat,level,id,args...) G_STMT_START{        \
789   if (G_UNLIKELY ((level) <= GST_LEVEL_MAX && (level) <= _gst_debug_min)) {                                             \
790     gst_debug_log_id ((cat), (level), __FILE__, GST_FUNCTION, __LINE__, \
791                       (id), ##args );                                   \
792   }                                                                     \
793 }G_STMT_END
794 #else /* no variadic macros, use inline */
795 static inline void
796 GST_CAT_LEVEL_LOG_ID_valist (GstDebugCategory * cat,
797     GstDebugLevel level, const gchar *id, const char *format, va_list varargs)
798 {
799   if (G_UNLIKELY ((level) <= GST_LEVEL_MAX && (level) <= _gst_debug_min)) {
800     gst_debug_log_id_valist (cat, level, "", "", 0, id, format,
801         varargs);
802   }
803 }
804
805 static inline void
806 GST_CAT_LEVEL_LOG_ID (GstDebugCategory * cat, GstDebugLevel level,
807     const gchar *id, const char *format, ...)
808 {
809   va_list varargs;
810
811   va_start (varargs, format);
812   GST_CAT_LEVEL_LOG_ID_valist (cat, level, id, format, varargs);
813   va_end (varargs);
814 }
815 #endif
816 #endif /* G_HAVE_ISO_VARARGS */
817
818 /* This one doesn't have varargs in the macro, so it's different than all the
819  * other macros and hence in a separate block right here. Docs chunks are
820  * with the other doc chunks below though. */
821 #define __GST_CAT_MEMDUMP_LOG(cat,object,msg,data,length) G_STMT_START{       \
822     if (G_UNLIKELY (GST_LEVEL_MEMDUMP <= GST_LEVEL_MAX &&                     \
823                     GST_LEVEL_MEMDUMP <= _gst_debug_min)) {                   \
824     _gst_debug_dump_mem ((cat), __FILE__, GST_FUNCTION, __LINE__,             \
825         (GObject *) (object), (msg), (data), (length));                       \
826   }                                                                           \
827 }G_STMT_END
828
829 /**
830  * __GST_CAT_MEMDUMP_LOG_ID:
831  *
832  * Only for private usage
833  *
834  * This one doesn't have varargs in the macro, so it's different than all the
835  * other macros and hence in a separate block right here. Docs chunks are
836  * with the other doc chunks below though.
837  *
838  * Since: 1.22
839  */
840 #define __GST_CAT_MEMDUMP_LOG_ID(cat,id,msg,data,length) G_STMT_START{  \
841     if (G_UNLIKELY (GST_LEVEL_MEMDUMP <= GST_LEVEL_MAX &&               \
842                     GST_LEVEL_MEMDUMP <= _gst_debug_min)) {             \
843       _gst_debug_dump_mem_id ((cat), __FILE__, GST_FUNCTION, __LINE__,  \
844                               (id), (msg), (data), (length));           \
845     }                                                                   \
846 }G_STMT_END
847
848 #define GST_CAT_MEMDUMP_OBJECT(cat,obj,msg,data,length)  \
849     __GST_CAT_MEMDUMP_LOG(cat,obj,msg,data,length)
850 #define GST_CAT_MEMDUMP_ID(cat,id,msg,data,length)      \
851     __GST_CAT_MEMDUMP_LOG_ID(cat,id,msg,data,length)
852 #define GST_CAT_MEMDUMP(cat,msg,data,length)             \
853     __GST_CAT_MEMDUMP_LOG(cat,NULL,msg,data,length)
854 #define GST_MEMDUMP_OBJECT(obj,msg,data,length)          \
855     __GST_CAT_MEMDUMP_LOG(GST_CAT_DEFAULT,obj,msg,data,length)
856 #define GST_MEMDUMP_ID(id,msg,data,length)          \
857     __GST_CAT_MEMDUMP_LOG_ID(GST_CAT_DEFAULT,id,msg,data,length)
858 #define GST_MEMDUMP(msg,data,length)                     \
859     __GST_CAT_MEMDUMP_LOG(GST_CAT_DEFAULT,NULL,msg,data,length)
860
861 /**
862  * GST_CAT_ERROR_OBJECT:
863  * @cat: category to use
864  * @obj: the #GObject the message belongs to
865  * @...: printf-style message to output
866  *
867  * Output an error message belonging to the given object in the given category.
868  *
869  * There is no need to finish the end of the message string with a newline
870  * character, a newline character will be added automatically.
871  */
872 /**
873  * GST_CAT_WARNING_OBJECT:
874  * @cat: category to use
875  * @obj: the #GObject the message belongs to
876  * @...: printf-style message to output
877  *
878  * Output a warning message belonging to the given object in the given category.
879  *
880  * There is no need to finish the end of the message string with a newline
881  * character, a newline character will be added automatically.
882  */
883 /**
884  * GST_CAT_INFO_OBJECT:
885  * @cat: category to use
886  * @obj: the #GObject the message belongs to
887  * @...: printf-style message to output
888  *
889  * Output an informational message belonging to the given object in the given
890  * category.
891  *
892  * There is no need to finish the end of the message string with a newline
893  * character, a newline character will be added automatically.
894  */
895 /**
896  * GST_CAT_DEBUG_OBJECT:
897  * @cat: category to use
898  * @obj: the #GObject the message belongs to
899  * @...: printf-style message to output
900  *
901  * Output an debugging message belonging to the given object in the given category.
902  *
903  * There is no need to finish the end of the message string with a newline
904  * character, a newline character will be added automatically.
905  */
906 /**
907  * GST_CAT_LOG_OBJECT:
908  * @cat: category to use
909  * @obj: the #GObject the message belongs to
910  * @...: printf-style message to output
911  *
912  * Output an logging message belonging to the given object in the given category.
913  *
914  * There is no need to finish the end of the message string with a newline
915  * character, a newline character will be added automatically.
916  */
917 /**
918  * GST_CAT_FIXME_OBJECT:
919  * @cat: category to use
920  * @obj: the #GObject the message belongs to
921  * @...: printf-style message to output
922  *
923  * Output a fixme message belonging to the given object in the given category.
924  *
925  * There is no need to finish the end of the message string with a newline
926  * character, a newline character will be added automatically.
927  */
928 /**
929  * GST_CAT_TRACE_OBJECT:
930  * @cat: category to use
931  * @obj: the #GObject the message belongs to
932  * @...: printf-style message to output
933  *
934  * Output a tracing message belonging to the given object in the given
935  * category.
936  *
937  * There is no need to finish the end of the message string with a newline
938  * character, a newline character will be added automatically.
939  */
940 /**
941  * GST_CAT_MEMDUMP_OBJECT:
942  * @cat: category to use
943  * @obj: the #GObject the message belongs to
944  * @msg: message string to log with the data
945  * @data: pointer to the data to output
946  * @length: length of the data to output
947  *
948  * Output a hexdump of @data relating to the given object in the given
949  * category.
950  *
951  * There is no need to finish the end of the message string with a newline
952  * character, a newline character will be added automatically.
953  */
954
955 /**
956  * GST_CAT_MEMDUMP_ID:
957  * @cat: category to use
958  * @id: An identifier of the message provider
959  * @msg: message string to log with the data
960  * @data: pointer to the data to output
961  * @length: length of the data to output
962  *
963  * Output a hexdump of @data relating to the given @id in the given category.
964  *
965  * There is no need to finish the end of the message string with a newline
966  * character, a newline character will be added automatically.
967  *
968  * Since: 1.22
969  */
970
971
972 /**
973  * GST_CAT_ERROR:
974  * @cat: category to use
975  * @...: printf-style message to output
976  *
977  * Output an error message in the given category.
978  *
979  * There is no need to finish the end of the message string with a newline
980  * character, a newline character will be added automatically.
981  */
982 /**
983  * GST_CAT_WARNING:
984  * @cat: category to use
985  * @...: printf-style message to output
986  *
987  * Output an warning message in the given category.
988  *
989  * There is no need to finish the end of the message string with a newline
990  * character, a newline character will be added automatically.
991  */
992 /**
993  * GST_CAT_INFO:
994  * @cat: category to use
995  * @...: printf-style message to output
996  *
997  * Output an informational message in the given category.
998  *
999  * There is no need to finish the end of the message string with a newline
1000  * character, a newline character will be added automatically.
1001  */
1002 /**
1003  * GST_CAT_DEBUG:
1004  * @cat: category to use
1005  * @...: printf-style message to output
1006  *
1007  * Output an debugging message in the given category.
1008  *
1009  * There is no need to finish the end of the message string with a newline
1010  * character, a newline character will be added automatically.
1011  */
1012 /**
1013  * GST_CAT_LOG:
1014  * @cat: category to use
1015  * @...: printf-style message to output
1016  *
1017  * Output an logging message in the given category.
1018  *
1019  * There is no need to finish the end of the message string with a newline
1020  * character, a newline character will be added automatically.
1021  */
1022 /**
1023  * GST_CAT_FIXME:
1024  * @cat: category to use
1025  * @...: printf-style message to output
1026  *
1027  * Output an fixme message in the given category.
1028  *
1029  * There is no need to finish the end of the message string with a newline
1030  * character, a newline character will be added automatically.
1031  */
1032 /**
1033  * GST_CAT_TRACE:
1034  * @cat: category to use
1035  * @...: printf-style message to output
1036  *
1037  * Output a tracing message in the given category.
1038  *
1039  * There is no need to finish the end of the message string with a newline
1040  * character, a newline character will be added automatically.
1041  */
1042 /**
1043  * GST_CAT_MEMDUMP:
1044  * @cat: category to use
1045  * @msg: message string to log with the data
1046  * @data: pointer to the data to output
1047  * @length: length of the data to output
1048  *
1049  * Output a hexdump of @data in the given category.
1050  *
1051  * There is no need to finish the end of the message string with a newline
1052  * character, a newline character will be added automatically.
1053  */
1054
1055
1056 /**
1057  * GST_ERROR_OBJECT:
1058  * @obj: the #GObject the message belongs to
1059  * @...: printf-style message to output
1060  *
1061  * Output an error message belonging to the given object in the default category.
1062  *
1063  * There is no need to finish the end of the message string with a newline
1064  * character, a newline character will be added automatically.
1065  */
1066 /**
1067  * GST_WARNING_OBJECT:
1068  * @obj: the #GObject the message belongs to
1069  * @...: printf-style message to output
1070  *
1071  * Output a warning message belonging to the given object in the default category.
1072  *
1073  * There is no need to finish the end of the message string with a newline
1074  * character, a newline character will be added automatically.
1075  */
1076 /**
1077  * GST_INFO_OBJECT:
1078  * @obj: the #GObject the message belongs to
1079  * @...: printf-style message to output
1080  *
1081  * Output an informational message belonging to the given object in the default
1082  * category.
1083  *
1084  * There is no need to finish the end of the message string with a newline
1085  * character, a newline character will be added automatically.
1086  */
1087 /**
1088  * GST_DEBUG_OBJECT:
1089  * @obj: the #GObject the message belongs to
1090  * @...: printf-style message to output
1091  *
1092  * Output a debugging message belonging to the given object in the default
1093  * category.
1094  *
1095  * There is no need to finish the end of the message string with a newline
1096  * character, a newline character will be added automatically.
1097  */
1098 /**
1099  * GST_LOG_OBJECT:
1100  * @obj: the #GObject the message belongs to
1101  * @...: printf-style message to output
1102  *
1103  * Output a logging message belonging to the given object in the default category.
1104  *
1105  * There is no need to finish the end of the message string with a newline
1106  * character, a newline character will be added automatically.
1107  */
1108 /**
1109  * GST_FIXME_OBJECT:
1110  * @obj: the #GObject the message belongs to
1111  * @...: printf-style message to output
1112  *
1113  * Output a fixme message belonging to the given object in the default category.
1114  *
1115  * There is no need to finish the end of the message string with a newline
1116  * character, a newline character will be added automatically.
1117  */
1118 /**
1119  * GST_TRACE_OBJECT:
1120  * @obj: the #GObject the message belongs to
1121  * @...: printf-style message to output
1122  *
1123  * Output a tracing message belonging to the given object in the default category.
1124  *
1125  * There is no need to finish the end of the message string with a newline
1126  * character, a newline character will be added automatically.
1127  */
1128 /**
1129  * GST_MEMDUMP_OBJECT:
1130  * @obj: the #GObject the message belongs to
1131  * @msg: message string to log with the data
1132  * @data: pointer to the data to output
1133  * @length: length of the data to output
1134  *
1135  * Output a logging message belonging to the given object in the default category.
1136  *
1137  * There is no need to finish the end of the message string with a newline
1138  * character, a newline character will be added automatically.
1139  */
1140
1141 /**
1142  * GST_ERROR_ID:
1143  * @id: An identifier of the message provider
1144  * @...: printf-style message to output
1145  *
1146  * Output an error message for the given identifier in the default category.
1147  *
1148  * There is no need to finish the end of the message string with a newline
1149  * character, a newline character will be added automatically.
1150  *
1151  * Since: 1.22
1152  */
1153 /**
1154  * GST_WARNING_ID:
1155  * @id: An identifier of the message provider
1156  * @...: printf-style message to output
1157  *
1158  * Output a warning message for the given identifier in the default category.
1159  *
1160  * There is no need to finish the end of the message string with a newline
1161  * character, a newline character will be added automatically.
1162  *
1163  * Since: 1.22
1164  */
1165 /**
1166  * GST_INFO_ID:
1167  * @id: An identifier of the message provider
1168  * @...: printf-style message to output
1169  *
1170  * Output an informational message for the given identifier the default
1171  * category.
1172  *
1173  * There is no need to finish the end of the message string with a newline
1174  * character, a newline character will be added automatically.
1175  *
1176  * Since: 1.22
1177  */
1178 /**
1179  * GST_DEBUG_ID:
1180  * @id: An identifier of the message provider
1181  * @...: printf-style message to output
1182  *
1183  * Output a debugging message for the given identifier in the default category.
1184  *
1185  * There is no need to finish the end of the message string with a newline
1186  * character, a newline character will be added automatically.
1187  *
1188  * Since: 1.22
1189  */
1190 /**
1191  * GST_LOG_ID:
1192  * @id: An identifier of the message provider
1193  * @...: printf-style message to output
1194  *
1195  * Output a logging message for the given identifier in the default category.
1196  *
1197  * There is no need to finish the end of the message string with a newline
1198  * character, a newline character will be added automatically.
1199  *
1200  * Since: 1.22
1201  */
1202 /**
1203  * GST_FIXME_ID:
1204  * @id: An identifier of the message provider
1205  * @...: printf-style message to output
1206  *
1207  * Output a fixme message for the given identifier in the default category.
1208  *
1209  * There is no need to finish the end of the message string with a newline
1210  * character, a newline character will be added automatically.
1211  *
1212  * Since: 1.22
1213  */
1214 /**
1215  * GST_TRACE_ID:
1216  * @id: An identifier of the message provider
1217  * @...: printf-style message to output
1218  *
1219  * Output a tracing message for the given identifier  in the default category.
1220  *
1221  * There is no need to finish the end of the message string with a newline
1222  * character, a newline character will be added automatically.
1223  *
1224  * Since: 1.22
1225  */
1226 /**
1227  * GST_MEMDUMP_ID:
1228  * @id: An identifier of the message provider
1229  * @msg: message string to log with the data
1230  * @data: pointer to the data to output
1231  * @length: length of the data to output
1232  *
1233  * Output a logging message belonging to the given object in the default category.
1234  *
1235  * There is no need to finish the end of the message string with a newline
1236  * character, a newline character will be added automatically.
1237  *
1238  * Since: 1.22
1239  */
1240
1241
1242
1243 /**
1244  * GST_ERROR:
1245  * @...: printf-style message to output
1246  *
1247  * Output an error message in the default category.
1248  *
1249  * There is no need to finish the end of the message string with a newline
1250  * character, a newline character will be added automatically.
1251  */
1252 /**
1253  * GST_WARNING:
1254  * @...: printf-style message to output
1255  *
1256  * Output a warning message in the default category.
1257  *
1258  * There is no need to finish the end of the message string with a newline
1259  * character, a newline character will be added automatically.
1260  */
1261 /**
1262  * GST_INFO:
1263  * @...: printf-style message to output
1264  *
1265  * Output an informational message in the default category.
1266  *
1267  * There is no need to finish the end of the message string with a newline
1268  * character, a newline character will be added automatically.
1269  */
1270 /**
1271  * GST_DEBUG:
1272  * @...: printf-style message to output
1273  *
1274  * Output a debugging message in the default category.
1275  *
1276  * There is no need to finish the end of the message string with a newline
1277  * character, a newline character will be added automatically.
1278  */
1279 /**
1280  * GST_LOG:
1281  * @...: printf-style message to output
1282  *
1283  * Output a logging message in the default category.
1284  *
1285  * There is no need to finish the end of the message string with a newline
1286  * character, a newline character will be added automatically.
1287  */
1288 /**
1289  * GST_FIXME:
1290  * @...: printf-style message to output
1291  *
1292  * Output a fixme message in the default category.
1293  *
1294  * There is no need to finish the end of the message string with a newline
1295  * character, a newline character will be added automatically.
1296  */
1297 /**
1298  * GST_TRACE:
1299  * @...: printf-style message to output
1300  *
1301  * Output a tracing message in the default category.
1302  *
1303  * There is no need to finish the end of the message string with a newline
1304  * character, a newline character will be added automatically.
1305  */
1306 /**
1307  * GST_MEMDUMP:
1308  * @msg: message string to log with the data
1309  * @data: pointer to the data to output
1310  * @length: length of the data to output
1311  *
1312  * Output a hexdump of @data.
1313  *
1314  * There is no need to finish the end of the message string with a newline
1315  * character, a newline character will be added automatically.
1316  */
1317
1318 #ifdef G_HAVE_ISO_VARARGS
1319
1320 #define GST_CAT_ERROR_OBJECT(cat,obj,...)       GST_CAT_LEVEL_LOG (cat, GST_LEVEL_ERROR,   obj,  __VA_ARGS__)
1321 #define GST_CAT_WARNING_OBJECT(cat,obj,...)     GST_CAT_LEVEL_LOG (cat, GST_LEVEL_WARNING, obj,  __VA_ARGS__)
1322 #define GST_CAT_INFO_OBJECT(cat,obj,...)        GST_CAT_LEVEL_LOG (cat, GST_LEVEL_INFO,    obj,  __VA_ARGS__)
1323 #define GST_CAT_DEBUG_OBJECT(cat,obj,...)       GST_CAT_LEVEL_LOG (cat, GST_LEVEL_DEBUG,   obj,  __VA_ARGS__)
1324 #define GST_CAT_LOG_OBJECT(cat,obj,...)         GST_CAT_LEVEL_LOG (cat, GST_LEVEL_LOG,     obj,  __VA_ARGS__)
1325 #define GST_CAT_FIXME_OBJECT(cat,obj,...)       GST_CAT_LEVEL_LOG (cat, GST_LEVEL_FIXME,   obj,  __VA_ARGS__)
1326 #define GST_CAT_TRACE_OBJECT(cat,obj,...)       GST_CAT_LEVEL_LOG (cat, GST_LEVEL_TRACE,   obj,  __VA_ARGS__)
1327
1328 #define GST_CAT_ERROR(cat,...)                  GST_CAT_LEVEL_LOG (cat, GST_LEVEL_ERROR,   NULL, __VA_ARGS__)
1329 #define GST_CAT_WARNING(cat,...)                GST_CAT_LEVEL_LOG (cat, GST_LEVEL_WARNING, NULL, __VA_ARGS__)
1330 #define GST_CAT_INFO(cat,...)                   GST_CAT_LEVEL_LOG (cat, GST_LEVEL_INFO,    NULL, __VA_ARGS__)
1331 #define GST_CAT_DEBUG(cat,...)                  GST_CAT_LEVEL_LOG (cat, GST_LEVEL_DEBUG,   NULL, __VA_ARGS__)
1332 #define GST_CAT_LOG(cat,...)                    GST_CAT_LEVEL_LOG (cat, GST_LEVEL_LOG,     NULL, __VA_ARGS__)
1333 #define GST_CAT_FIXME(cat,...)                  GST_CAT_LEVEL_LOG (cat, GST_LEVEL_FIXME,   NULL, __VA_ARGS__)
1334 #define GST_CAT_TRACE(cat,...)          GST_CAT_LEVEL_LOG (cat, GST_LEVEL_TRACE,   NULL, __VA_ARGS__)
1335
1336 #define GST_ERROR_OBJECT(obj,...)       GST_CAT_LEVEL_LOG (GST_CAT_DEFAULT, GST_LEVEL_ERROR,   obj,  __VA_ARGS__)
1337 #define GST_WARNING_OBJECT(obj,...)     GST_CAT_LEVEL_LOG (GST_CAT_DEFAULT, GST_LEVEL_WARNING, obj,  __VA_ARGS__)
1338 #define GST_INFO_OBJECT(obj,...)        GST_CAT_LEVEL_LOG (GST_CAT_DEFAULT, GST_LEVEL_INFO,    obj,  __VA_ARGS__)
1339 #define GST_DEBUG_OBJECT(obj,...)       GST_CAT_LEVEL_LOG (GST_CAT_DEFAULT, GST_LEVEL_DEBUG,   obj,  __VA_ARGS__)
1340 #define GST_LOG_OBJECT(obj,...)         GST_CAT_LEVEL_LOG (GST_CAT_DEFAULT, GST_LEVEL_LOG,     obj,  __VA_ARGS__)
1341 #define GST_FIXME_OBJECT(obj,...)       GST_CAT_LEVEL_LOG (GST_CAT_DEFAULT, GST_LEVEL_FIXME,   obj,  __VA_ARGS__)
1342 #define GST_TRACE_OBJECT(obj,...)       GST_CAT_LEVEL_LOG (GST_CAT_DEFAULT, GST_LEVEL_TRACE,   obj,  __VA_ARGS__)
1343
1344 #define GST_ERROR_ID(id,...)    GST_CAT_LEVEL_LOG_ID (GST_CAT_DEFAULT, GST_LEVEL_ERROR,   id,  __VA_ARGS__)
1345 #define GST_WARNING_ID(id,...)  GST_CAT_LEVEL_LOG_ID (GST_CAT_DEFAULT, GST_LEVEL_WARNING, id,  __VA_ARGS__)
1346 #define GST_INFO_ID(id,...)     GST_CAT_LEVEL_LOG_ID (GST_CAT_DEFAULT, GST_LEVEL_INFO,    id,  __VA_ARGS__)
1347 #define GST_DEBUG_ID(id,...)    GST_CAT_LEVEL_LOG_ID (GST_CAT_DEFAULT, GST_LEVEL_DEBUG,   id,  __VA_ARGS__)
1348 #define GST_LOG_ID(id,...)      GST_CAT_LEVEL_LOG_ID (GST_CAT_DEFAULT, GST_LEVEL_LOG,     id,  __VA_ARGS__)
1349 #define GST_FIXME_ID(id,...)    GST_CAT_LEVEL_LOG_ID (GST_CAT_DEFAULT, GST_LEVEL_FIXME,   id,  __VA_ARGS__)
1350 #define GST_TRACE_ID(id,...)    GST_CAT_LEVEL_LOG_ID (GST_CAT_DEFAULT, GST_LEVEL_TRACE,   id,  __VA_ARGS__)
1351
1352 #define GST_ERROR(...)                  GST_CAT_LEVEL_LOG (GST_CAT_DEFAULT, GST_LEVEL_ERROR,   NULL, __VA_ARGS__)
1353 #define GST_WARNING(...)                GST_CAT_LEVEL_LOG (GST_CAT_DEFAULT, GST_LEVEL_WARNING, NULL, __VA_ARGS__)
1354 #define GST_INFO(...)                   GST_CAT_LEVEL_LOG (GST_CAT_DEFAULT, GST_LEVEL_INFO,    NULL, __VA_ARGS__)
1355 #define GST_DEBUG(...)                  GST_CAT_LEVEL_LOG (GST_CAT_DEFAULT, GST_LEVEL_DEBUG,   NULL, __VA_ARGS__)
1356 #define GST_LOG(...)                    GST_CAT_LEVEL_LOG (GST_CAT_DEFAULT, GST_LEVEL_LOG,     NULL, __VA_ARGS__)
1357 #define GST_FIXME(...)                  GST_CAT_LEVEL_LOG (GST_CAT_DEFAULT, GST_LEVEL_FIXME,   NULL, __VA_ARGS__)
1358 #define GST_TRACE(...)          GST_CAT_LEVEL_LOG (GST_CAT_DEFAULT, GST_LEVEL_TRACE,   NULL, __VA_ARGS__)
1359
1360 #else
1361 #ifdef G_HAVE_GNUC_VARARGS
1362
1363 #define GST_CAT_ERROR_OBJECT(cat,obj,args...)   GST_CAT_LEVEL_LOG (cat, GST_LEVEL_ERROR,   obj,  ##args )
1364 #define GST_CAT_WARNING_OBJECT(cat,obj,args...) GST_CAT_LEVEL_LOG (cat, GST_LEVEL_WARNING, obj,  ##args )
1365 #define GST_CAT_INFO_OBJECT(cat,obj,args...)    GST_CAT_LEVEL_LOG (cat, GST_LEVEL_INFO,    obj,  ##args )
1366 #define GST_CAT_DEBUG_OBJECT(cat,obj,args...)   GST_CAT_LEVEL_LOG (cat, GST_LEVEL_DEBUG,   obj,  ##args )
1367 #define GST_CAT_LOG_OBJECT(cat,obj,args...)     GST_CAT_LEVEL_LOG (cat, GST_LEVEL_LOG,     obj,  ##args )
1368 #define GST_CAT_FIXME_OBJECT(cat,obj,args...)   GST_CAT_LEVEL_LOG (cat, GST_LEVEL_FIXME,   obj,  ##args )
1369 #define GST_CAT_TRACE_OBJECT(cat,obj,args...)   GST_CAT_LEVEL_LOG (cat, GST_LEVEL_TRACE,   obj,  ##args )
1370
1371 #define GST_CAT_ERROR(cat,args...)              GST_CAT_LEVEL_LOG (cat, GST_LEVEL_ERROR,   NULL, ##args )
1372 #define GST_CAT_WARNING(cat,args...)            GST_CAT_LEVEL_LOG (cat, GST_LEVEL_WARNING, NULL, ##args )
1373 #define GST_CAT_INFO(cat,args...)               GST_CAT_LEVEL_LOG (cat, GST_LEVEL_INFO,    NULL, ##args )
1374 #define GST_CAT_DEBUG(cat,args...)              GST_CAT_LEVEL_LOG (cat, GST_LEVEL_DEBUG,   NULL, ##args )
1375 #define GST_CAT_LOG(cat,args...)                GST_CAT_LEVEL_LOG (cat, GST_LEVEL_LOG,     NULL, ##args )
1376 #define GST_CAT_FIXME(cat,args...)              GST_CAT_LEVEL_LOG (cat, GST_LEVEL_FIXME,   NULL, ##args )
1377 #define GST_CAT_TRACE(cat,args...)              GST_CAT_LEVEL_LOG (cat, GST_LEVEL_TRACE,   NULL, ##args )
1378
1379 #define GST_ERROR_OBJECT(obj,args...)   GST_CAT_LEVEL_LOG (GST_CAT_DEFAULT, GST_LEVEL_ERROR,   obj,  ##args )
1380 #define GST_WARNING_OBJECT(obj,args...) GST_CAT_LEVEL_LOG (GST_CAT_DEFAULT, GST_LEVEL_WARNING, obj,  ##args )
1381 #define GST_INFO_OBJECT(obj,args...)    GST_CAT_LEVEL_LOG (GST_CAT_DEFAULT, GST_LEVEL_INFO,    obj,  ##args )
1382 #define GST_DEBUG_OBJECT(obj,args...)   GST_CAT_LEVEL_LOG (GST_CAT_DEFAULT, GST_LEVEL_DEBUG,   obj,  ##args )
1383 #define GST_LOG_OBJECT(obj,args...)     GST_CAT_LEVEL_LOG (GST_CAT_DEFAULT, GST_LEVEL_LOG,     obj,  ##args )
1384 #define GST_FIXME_OBJECT(obj,args...)   GST_CAT_LEVEL_LOG (GST_CAT_DEFAULT, GST_LEVEL_FIXME,   obj,  ##args )
1385 #define GST_TRACE_OBJECT(obj,args...)   GST_CAT_LEVEL_LOG (GST_CAT_DEFAULT, GST_LEVEL_TRACE,   obj,  ##args )
1386
1387 #define GST_ERROR_ID(id,args...)        GST_CAT_LEVEL_LOG (GST_CAT_DEFAULT, GST_LEVEL_ERROR,   id,  ##args )
1388 #define GST_WARNING_ID(id,args...) GST_CAT_LEVEL_LOG (GST_CAT_DEFAULT, GST_LEVEL_WARNING, id,  ##args )
1389 #define GST_INFO_ID(id,args...) GST_CAT_LEVEL_LOG (GST_CAT_DEFAULT, GST_LEVEL_INFO,    id,  ##args )
1390 #define GST_DEBUG_ID(id,args...)        GST_CAT_LEVEL_LOG (GST_CAT_DEFAULT, GST_LEVEL_DEBUG,   id,  ##args )
1391 #define GST_LOG_ID(id,args...)  GST_CAT_LEVEL_LOG (GST_CAT_DEFAULT, GST_LEVEL_LOG,     id,  ##args )
1392 #define GST_FIXME_ID(id,args...)        GST_CAT_LEVEL_LOG (GST_CAT_DEFAULT, GST_LEVEL_FIXME,   id,  ##args )
1393 #define GST_TRACE_ID(id,args...)        GST_CAT_LEVEL_LOG (GST_CAT_DEFAULT, GST_LEVEL_TRACE,   id,  ##args )
1394
1395 #define GST_ERROR(args...)              GST_CAT_LEVEL_LOG (GST_CAT_DEFAULT, GST_LEVEL_ERROR,   NULL, ##args )
1396 #define GST_WARNING(args...)            GST_CAT_LEVEL_LOG (GST_CAT_DEFAULT, GST_LEVEL_WARNING, NULL, ##args )
1397 #define GST_INFO(args...)               GST_CAT_LEVEL_LOG (GST_CAT_DEFAULT, GST_LEVEL_INFO,    NULL, ##args )
1398 #define GST_DEBUG(args...)              GST_CAT_LEVEL_LOG (GST_CAT_DEFAULT, GST_LEVEL_DEBUG,   NULL, ##args )
1399 #define GST_LOG(args...)                GST_CAT_LEVEL_LOG (GST_CAT_DEFAULT, GST_LEVEL_LOG,     NULL, ##args )
1400 #define GST_FIXME(args...)              GST_CAT_LEVEL_LOG (GST_CAT_DEFAULT, GST_LEVEL_FIXME,   NULL, ##args )
1401 #define GST_TRACE(args...)              GST_CAT_LEVEL_LOG (GST_CAT_DEFAULT, GST_LEVEL_TRACE,   NULL, ##args )
1402
1403 #else
1404 /* no variadic macros, use inline */
1405 static inline void
1406 GST_CAT_ERROR_OBJECT (GstDebugCategory * cat, gpointer obj, const char *format,
1407     ...)
1408 {
1409   va_list varargs;
1410
1411   va_start (varargs, format);
1412   GST_CAT_LEVEL_LOG_valist (cat, GST_LEVEL_ERROR, obj, format, varargs);
1413   va_end (varargs);
1414 }
1415
1416 static inline void
1417 GST_CAT_WARNING_OBJECT (GstDebugCategory * cat, gpointer obj,
1418     const char *format, ...)
1419 {
1420   va_list varargs;
1421
1422   va_start (varargs, format);
1423   GST_CAT_LEVEL_LOG_valist (cat, GST_LEVEL_WARNING, obj, format, varargs);
1424   va_end (varargs);
1425 }
1426
1427 static inline void
1428 GST_CAT_INFO_OBJECT (GstDebugCategory * cat, gpointer obj, const char *format,
1429     ...)
1430 {
1431   va_list varargs;
1432
1433   va_start (varargs, format);
1434   GST_CAT_LEVEL_LOG_valist (cat, GST_LEVEL_INFO, obj, format, varargs);
1435   va_end (varargs);
1436 }
1437
1438 static inline void
1439 GST_CAT_DEBUG_OBJECT (GstDebugCategory * cat, gpointer obj, const char *format,
1440     ...)
1441 {
1442   va_list varargs;
1443
1444   va_start (varargs, format);
1445   GST_CAT_LEVEL_LOG_valist (cat, GST_LEVEL_DEBUG, obj, format, varargs);
1446   va_end (varargs);
1447 }
1448
1449 static inline void
1450 GST_CAT_LOG_OBJECT (GstDebugCategory * cat, gpointer obj, const char *format,
1451     ...)
1452 {
1453   va_list varargs;
1454
1455   va_start (varargs, format);
1456   GST_CAT_LEVEL_LOG_valist (cat, GST_LEVEL_LOG, obj, format, varargs);
1457   va_end (varargs);
1458 }
1459
1460 static inline void
1461 GST_CAT_FIXME_OBJECT (GstDebugCategory * cat, gpointer obj, const char *format,
1462     ...)
1463 {
1464   va_list varargs;
1465
1466   va_start (varargs, format);
1467   GST_CAT_LEVEL_LOG_valist (cat, GST_LEVEL_FIXME, obj, format, varargs);
1468   va_end (varargs);
1469 }
1470
1471 static inline void
1472 GST_CAT_TRACE_OBJECT (GstDebugCategory * cat, gpointer obj, const char *format,
1473     ...)
1474 {
1475   va_list varargs;
1476
1477   va_start (varargs, format);
1478   GST_CAT_LEVEL_LOG_valist (cat, GST_LEVEL_TRACE, obj, format, varargs);
1479   va_end (varargs);
1480 }
1481
1482 static inline void
1483 GST_CAT_ERROR (GstDebugCategory * cat, const char *format, ...)
1484 {
1485   va_list varargs;
1486
1487   va_start (varargs, format);
1488   GST_CAT_LEVEL_LOG_valist (cat, GST_LEVEL_ERROR, NULL, format, varargs);
1489   va_end (varargs);
1490 }
1491
1492 static inline void
1493 GST_CAT_WARNING (GstDebugCategory * cat, const char *format, ...)
1494 {
1495   va_list varargs;
1496
1497   va_start (varargs, format);
1498   GST_CAT_LEVEL_LOG_valist (cat, GST_LEVEL_WARNING, NULL, format, varargs);
1499   va_end (varargs);
1500 }
1501
1502 static inline void
1503 GST_CAT_INFO (GstDebugCategory * cat, const char *format, ...)
1504 {
1505   va_list varargs;
1506
1507   va_start (varargs, format);
1508   GST_CAT_LEVEL_LOG_valist (cat, GST_LEVEL_INFO, NULL, format, varargs);
1509   va_end (varargs);
1510 }
1511
1512 static inline void
1513 GST_CAT_DEBUG (GstDebugCategory * cat, const char *format, ...)
1514 {
1515   va_list varargs;
1516
1517   va_start (varargs, format);
1518   GST_CAT_LEVEL_LOG_valist (cat, GST_LEVEL_DEBUG, NULL, format, varargs);
1519   va_end (varargs);
1520 }
1521
1522 static inline void
1523 GST_CAT_LOG (GstDebugCategory * cat, const char *format, ...)
1524 {
1525   va_list varargs;
1526
1527   va_start (varargs, format);
1528   GST_CAT_LEVEL_LOG_valist (cat, GST_LEVEL_LOG, NULL, format, varargs);
1529   va_end (varargs);
1530 }
1531
1532 static inline void
1533 GST_CAT_FIXME (GstDebugCategory * cat, const char *format, ...)
1534 {
1535   va_list varargs;
1536
1537   va_start (varargs, format);
1538   GST_CAT_LEVEL_LOG_valist (cat, GST_LEVEL_FIXME, NULL, format, varargs);
1539   va_end (varargs);
1540 }
1541
1542 static inline void
1543 GST_CAT_TRACE (GstDebugCategory * cat, const char *format, ...)
1544 {
1545   va_list varargs;
1546
1547   va_start (varargs, format);
1548   GST_CAT_LEVEL_LOG_valist (cat, GST_LEVEL_TRACE, NULL, format, varargs);
1549   va_end (varargs);
1550 }
1551
1552 static inline void
1553 GST_ERROR_OBJECT (gpointer obj, const char *format, ...)
1554 {
1555   va_list varargs;
1556
1557   va_start (varargs, format);
1558   GST_CAT_LEVEL_LOG_valist (GST_CAT_DEFAULT, GST_LEVEL_ERROR, obj, format,
1559       varargs);
1560   va_end (varargs);
1561 }
1562
1563 static inline void
1564 GST_WARNING_OBJECT (gpointer obj, const char *format, ...)
1565 {
1566   va_list varargs;
1567
1568   va_start (varargs, format);
1569   GST_CAT_LEVEL_LOG_valist (GST_CAT_DEFAULT, GST_LEVEL_WARNING, obj, format,
1570       varargs);
1571   va_end (varargs);
1572 }
1573
1574 static inline void
1575 GST_INFO_OBJECT (gpointer obj, const char *format, ...)
1576 {
1577   va_list varargs;
1578
1579   va_start (varargs, format);
1580   GST_CAT_LEVEL_LOG_valist (GST_CAT_DEFAULT, GST_LEVEL_INFO, obj, format,
1581       varargs);
1582   va_end (varargs);
1583 }
1584
1585 static inline void
1586 GST_DEBUG_OBJECT (gpointer obj, const char *format, ...)
1587 {
1588   va_list varargs;
1589
1590   va_start (varargs, format);
1591   GST_CAT_LEVEL_LOG_valist (GST_CAT_DEFAULT, GST_LEVEL_DEBUG, obj, format,
1592       varargs);
1593   va_end (varargs);
1594 }
1595
1596 static inline void
1597 GST_LOG_OBJECT (gpointer obj, const char *format, ...)
1598 {
1599   va_list varargs;
1600
1601   va_start (varargs, format);
1602   GST_CAT_LEVEL_LOG_valist (GST_CAT_DEFAULT, GST_LEVEL_LOG, obj, format,
1603       varargs);
1604   va_end (varargs);
1605 }
1606
1607 static inline void
1608 GST_FIXME_OBJECT (gpointer obj, const char *format, ...)
1609 {
1610   va_list varargs;
1611
1612   va_start (varargs, format);
1613   GST_CAT_LEVEL_LOG_valist (GST_CAT_DEFAULT, GST_LEVEL_FIXME, obj, format,
1614       varargs);
1615   va_end (varargs);
1616 }
1617
1618 static inline void
1619 GST_TRACE_OBJECT (gpointer obj, const char *format, ...)
1620 {
1621   va_list varargs;
1622
1623   va_start (varargs, format);
1624   GST_CAT_LEVEL_LOG_valist (GST_CAT_DEFAULT, GST_LEVEL_TRACE, obj, format,
1625       varargs);
1626   va_end (varargs);
1627 }
1628
1629 static inline void
1630 GST_ERROR_ID (const gchar *id, const char *format, ...)
1631 {
1632   va_list varargs;
1633
1634   va_start (varargs, format);
1635   GST_CAT_LEVEL_LOG_ID_valist (GST_CAT_DEFAULT, GST_LEVEL_ERROR, id, format,
1636       varargs);
1637   va_end (varargs);
1638 }
1639
1640 static inline void
1641 GST_WARNING_ID (const gchar *id, const char *format, ...)
1642 {
1643   va_list varargs;
1644
1645   va_start (varargs, format);
1646   GST_CAT_LEVEL_LOG_ID_valist (GST_CAT_DEFAULT, GST_LEVEL_WARNING, id, format,
1647       varargs);
1648   va_end (varargs);
1649 }
1650
1651 static inline void
1652 GST_INFO_ID (const gchar *id, const char *format, ...)
1653 {
1654   va_list varargs;
1655
1656   va_start (varargs, format);
1657   GST_CAT_LEVEL_LOG_ID_valist (GST_CAT_DEFAULT, GST_LEVEL_INFO, id, format,
1658       varargs);
1659   va_end (varargs);
1660 }
1661
1662 static inline void
1663 GST_DEBUG_ID (const gchar *id, const char *format, ...)
1664 {
1665   va_list varargs;
1666
1667   va_start (varargs, format);
1668   GST_CAT_LEVEL_LOG_ID_valist (GST_CAT_DEFAULT, GST_LEVEL_DEBUG, id, format,
1669       varargs);
1670   va_end (varargs);
1671 }
1672
1673 static inline void
1674 GST_LOG_ID (const gchar *id, const char *format, ...)
1675 {
1676   va_list varargs;
1677
1678   va_start (varargs, format);
1679   GST_CAT_LEVEL_LOG_ID_valist (GST_CAT_DEFAULT, GST_LEVEL_LOG, id, format,
1680       varargs);
1681   va_end (varargs);
1682 }
1683
1684 static inline void
1685 GST_FIXME_ID (const gchar *id, const char *format, ...)
1686 {
1687   va_list varargs;
1688
1689   va_start (varargs, format);
1690   GST_CAT_LEVEL_LOG_ID_valist (GST_CAT_DEFAULT, GST_LEVEL_FIXME, id, format,
1691       varargs);
1692   va_end (varargs);
1693 }
1694
1695 static inline void
1696 GST_TRACE_ID (const gchar *id, const char *format, ...)
1697 {
1698   va_list varargs;
1699
1700   va_start (varargs, format);
1701   GST_CAT_LEVEL_LOG_ID_valist (GST_CAT_DEFAULT, GST_LEVEL_TRACE, id, format,
1702       varargs);
1703   va_end (varargs);
1704 }
1705
1706 static inline void
1707 GST_ERROR (const char *format, ...)
1708 {
1709   va_list varargs;
1710
1711   va_start (varargs, format);
1712   GST_CAT_LEVEL_LOG_valist (GST_CAT_DEFAULT, GST_LEVEL_ERROR, NULL, format,
1713       varargs);
1714   va_end (varargs);
1715 }
1716
1717 static inline void
1718 GST_WARNING (const char *format, ...)
1719 {
1720   va_list varargs;
1721
1722   va_start (varargs, format);
1723   GST_CAT_LEVEL_LOG_valist (GST_CAT_DEFAULT, GST_LEVEL_WARNING, NULL, format,
1724       varargs);
1725   va_end (varargs);
1726 }
1727
1728 static inline void
1729 GST_INFO (const char *format, ...)
1730 {
1731   va_list varargs;
1732
1733   va_start (varargs, format);
1734   GST_CAT_LEVEL_LOG_valist (GST_CAT_DEFAULT, GST_LEVEL_INFO, NULL, format,
1735       varargs);
1736   va_end (varargs);
1737 }
1738
1739 static inline void
1740 GST_DEBUG (const char *format, ...)
1741 {
1742   va_list varargs;
1743
1744   va_start (varargs, format);
1745   GST_CAT_LEVEL_LOG_valist (GST_CAT_DEFAULT, GST_LEVEL_DEBUG, NULL, format,
1746       varargs);
1747   va_end (varargs);
1748 }
1749
1750 static inline void
1751 GST_LOG (const char *format, ...)
1752 {
1753   va_list varargs;
1754
1755   va_start (varargs, format);
1756   GST_CAT_LEVEL_LOG_valist (GST_CAT_DEFAULT, GST_LEVEL_LOG, NULL,
1757       format, varargs);
1758   va_end (varargs);
1759 }
1760
1761 static inline void
1762 GST_FIXME (const char *format, ...)
1763 {
1764   va_list varargs;
1765
1766   va_start (varargs, format);
1767   GST_CAT_LEVEL_LOG_valist (GST_CAT_DEFAULT, GST_LEVEL_FIXME, NULL, format,
1768       varargs);
1769   va_end (varargs);
1770 }
1771
1772 static inline void
1773 GST_TRACE (const char *format, ...)
1774 {
1775   va_list varargs;
1776
1777   va_start (varargs, format);
1778   GST_CAT_LEVEL_LOG_valist (GST_CAT_DEFAULT, GST_LEVEL_TRACE, NULL, format,
1779       varargs);
1780   va_end (varargs);
1781 }
1782 #endif
1783 #endif
1784
1785
1786 /********** function pointer stuff **********/
1787
1788 /**
1789  * GST_DEBUG_REGISTER_FUNCPTR:
1790  * @ptr: pointer to the function to register
1791  *
1792  * Register a pointer to a function with its name, so it can later be used by
1793  * GST_DEBUG_FUNCPTR_NAME().
1794  *
1795  * Use this variant of #GST_DEBUG_FUNCPTR if you do not need to use @ptr.
1796  */
1797 #define GST_DEBUG_REGISTER_FUNCPTR(ptr) \
1798   _gst_debug_register_funcptr((GstDebugFuncPtr)(ptr), #ptr)
1799 /**
1800  * GST_DEBUG_FUNCPTR:
1801  * @ptr: pointer to the function to register
1802  *
1803  * Register a pointer to a function with its name, so it can later be used by
1804  * GST_DEBUG_FUNCPTR_NAME().
1805  *
1806  * Returns: the value passed to @ptr.
1807  */
1808 #define GST_DEBUG_FUNCPTR(ptr) \
1809   (_gst_debug_register_funcptr((GstDebugFuncPtr)(ptr), #ptr) , ptr)
1810
1811 /**
1812  * GST_DEBUG_FUNCPTR_NAME:
1813  * @ptr: address of the function of which to look up the name
1814  *
1815  * Retrieves the name of the function, if it was previously registered with
1816  * GST_DEBUG_FUNCPTR(). If not, it returns a description of the pointer.
1817  *
1818  * This macro returns a constant string which must not be modified or
1819  * freed by the caller.
1820  */
1821 #define GST_DEBUG_FUNCPTR_NAME(ptr) \
1822   _gst_debug_nameof_funcptr((GstDebugFuncPtr)ptr)
1823
1824
1825 #else /* GST_DISABLE_GST_DEBUG */
1826
1827
1828 #ifndef GST_INFO_C
1829
1830 #if defined(__GNUC__) && __GNUC__ >= 3
1831 #  pragma GCC poison gst_debug_log
1832 #  pragma GCC poison gst_debug_log_valist
1833 #  pragma GCC poison gst_debug_log_literal
1834 #  pragma GCC poison gst_debug_log_id
1835 #  pragma GCC poison gst_debug_log_id_valist
1836 #  pragma GCC poison gst_debug_log_id_literal
1837 #  pragma GCC poison _gst_debug_category_new
1838 #endif
1839
1840 #define _gst_debug_min GST_LEVEL_NONE
1841
1842 #define gst_debug_set_default_threshold(level)          G_STMT_START{ }G_STMT_END
1843 #define gst_debug_get_default_threshold()               (GST_LEVEL_NONE)
1844
1845 #define gst_debug_level_get_name(level)                         ("NONE")
1846 #define gst_debug_message_get(message)                          ("")
1847 #define gst_debug_message_get_id(message)                       (NULL)
1848 #define gst_debug_add_log_function(func,data,notify)    G_STMT_START{ }G_STMT_END
1849 #define gst_debug_set_active(active)                    G_STMT_START{ }G_STMT_END
1850 #define gst_debug_is_active()                           (FALSE)
1851 #define gst_debug_set_colored(colored)                  G_STMT_START{ }G_STMT_END
1852 #define gst_debug_set_color_mode(mode)                  G_STMT_START{ }G_STMT_END
1853 #define gst_debug_set_color_mode_from_string(mode)      G_STMT_START{ }G_STMT_END
1854 #define gst_debug_is_colored()                          (FALSE)
1855 #define gst_debug_get_color_mode()                      (GST_DEBUG_COLOR_MODE_OFF)
1856 #define gst_debug_set_default_threshold(level)          G_STMT_START{ }G_STMT_END
1857 #define gst_debug_get_default_threshold()               (GST_LEVEL_NONE)
1858 #define gst_debug_set_threshold_for_name(name,level)    G_STMT_START{ }G_STMT_END
1859 #define gst_debug_unset_threshold_for_name(name)        G_STMT_START{ }G_STMT_END
1860
1861 /* we are using dummy function prototypes here to eat ';' as these macros are
1862  * used outside of functions */
1863 #define GST_DEBUG_CATEGORY(var)                         void _gst_debug_dummy_##var (void)
1864 #define GST_DEBUG_CATEGORY_EXTERN(var)                  void _gst_debug_dummy_extern_##var (void)
1865 #define GST_DEBUG_CATEGORY_STATIC(var)                  void _gst_debug_dummy_static_##var (void)
1866
1867 #define GST_DEBUG_CATEGORY_INIT(var,name,color,desc)    G_STMT_START{ }G_STMT_END
1868 #define GST_DEBUG_CATEGORY_GET(var,name)                G_STMT_START{ }G_STMT_END
1869 #ifndef GST_DISABLE_DEPRECATED
1870 #define gst_debug_category_free(category)               G_STMT_START{ }G_STMT_END
1871 #endif
1872 #define gst_debug_category_set_threshold(category,level) G_STMT_START{ }G_STMT_END
1873 #define gst_debug_category_reset_threshold(category)    G_STMT_START{ }G_STMT_END
1874 #define gst_debug_category_get_threshold(category)      (GST_LEVEL_NONE)
1875 #define gst_debug_category_get_name(cat)                ("")
1876 #define gst_debug_category_get_color(cat)               (0)
1877 #define gst_debug_category_get_description(cat)         ("")
1878 #define gst_debug_get_all_categories()                  (NULL)
1879 #define gst_debug_construct_term_color(colorinfo)       (g_strdup ("00"))
1880 #define gst_debug_construct_win_color(colorinfo)        (0)
1881
1882 #endif /* !GST_INFO_C */
1883
1884 #ifdef G_HAVE_ISO_VARARGS
1885
1886 #define GST_CAT_LEVEL_LOG(cat,level,...)                G_STMT_START{ }G_STMT_END
1887
1888 #define GST_CAT_ERROR_OBJECT(...)                       G_STMT_START{ }G_STMT_END
1889 #define GST_CAT_WARNING_OBJECT(...)                     G_STMT_START{ }G_STMT_END
1890 #define GST_CAT_INFO_OBJECT(...)                        G_STMT_START{ }G_STMT_END
1891 #define GST_CAT_DEBUG_OBJECT(...)                       G_STMT_START{ }G_STMT_END
1892 #define GST_CAT_LOG_OBJECT(...)                         G_STMT_START{ }G_STMT_END
1893 #define GST_CAT_FIXME_OBJECT(...)                       G_STMT_START{ }G_STMT_END
1894 #define GST_CAT_TRACE_OBJECT(...)                       G_STMT_START{ }G_STMT_END
1895
1896 #define GST_CAT_ERROR(...)                              G_STMT_START{ }G_STMT_END
1897 #define GST_CAT_WARNING(...)                            G_STMT_START{ }G_STMT_END
1898 #define GST_CAT_INFO(...)                               G_STMT_START{ }G_STMT_END
1899 #define GST_CAT_DEBUG(...)                              G_STMT_START{ }G_STMT_END
1900 #define GST_CAT_LOG(...)                                G_STMT_START{ }G_STMT_END
1901 #define GST_CAT_FIXME(...)                              G_STMT_START{ }G_STMT_END
1902 #define GST_CAT_TRACE(...)                              G_STMT_START{ }G_STMT_END
1903
1904 #define GST_ERROR_OBJECT(...)                           G_STMT_START{ }G_STMT_END
1905 #define GST_WARNING_OBJECT(...)                         G_STMT_START{ }G_STMT_END
1906 #define GST_INFO_OBJECT(...)                            G_STMT_START{ }G_STMT_END
1907 #define GST_DEBUG_OBJECT(...)                           G_STMT_START{ }G_STMT_END
1908 #define GST_LOG_OBJECT(...)                             G_STMT_START{ }G_STMT_END
1909 #define GST_FIXME_OBJECT(...)                           G_STMT_START{ }G_STMT_END
1910 #define GST_TRACE_OBJECT(...)                           G_STMT_START{ }G_STMT_END
1911
1912 #define GST_ERROR_ID(...)                       G_STMT_START{ }G_STMT_END
1913 #define GST_WARNING_ID(...)                     G_STMT_START{ }G_STMT_END
1914 #define GST_INFO_ID(...)                                G_STMT_START{ }G_STMT_END
1915 #define GST_DEBUG_ID(...)                       G_STMT_START{ }G_STMT_END
1916 #define GST_LOG_ID(...)                         G_STMT_START{ }G_STMT_END
1917 #define GST_FIXME_ID(...)                       G_STMT_START{ }G_STMT_END
1918 #define GST_TRACE_ID(...)                       G_STMT_START{ }G_STMT_END
1919
1920 #define GST_ERROR(...)                                  G_STMT_START{ }G_STMT_END
1921 #define GST_WARNING(...)                                G_STMT_START{ }G_STMT_END
1922 #define GST_INFO(...)                                   G_STMT_START{ }G_STMT_END
1923 #define GST_DEBUG(...)                                  G_STMT_START{ }G_STMT_END
1924 #define GST_LOG(...)                                    G_STMT_START{ }G_STMT_END
1925 #define GST_FIXME(...)                                  G_STMT_START{ }G_STMT_END
1926 #define GST_TRACE(...)                                  G_STMT_START{ }G_STMT_END
1927
1928 #else /* !G_HAVE_ISO_VARARGS */
1929 #ifdef G_HAVE_GNUC_VARARGS
1930
1931 #define GST_CAT_LEVEL_LOG(cat,level,args...)            G_STMT_START{ }G_STMT_END
1932
1933 #define GST_CAT_ERROR_OBJECT(args...)                   G_STMT_START{ }G_STMT_END
1934 #define GST_CAT_WARNING_OBJECT(args...)                 G_STMT_START{ }G_STMT_END
1935 #define GST_CAT_INFO_OBJECT(args...)                    G_STMT_START{ }G_STMT_END
1936 #define GST_CAT_DEBUG_OBJECT(args...)                   G_STMT_START{ }G_STMT_END
1937 #define GST_CAT_LOG_OBJECT(args...)                     G_STMT_START{ }G_STMT_END
1938 #define GST_CAT_FIXME_OBJECT(args...)                   G_STMT_START{ }G_STMT_END
1939 #define GST_CAT_TRACE_OBJECT(args...)                   G_STMT_START{ }G_STMT_END
1940
1941 #define GST_CAT_ERROR(args...)                          G_STMT_START{ }G_STMT_END
1942 #define GST_CAT_WARNING(args...)                        G_STMT_START{ }G_STMT_END
1943 #define GST_CAT_INFO(args...)                           G_STMT_START{ }G_STMT_END
1944 #define GST_CAT_DEBUG(args...)                          G_STMT_START{ }G_STMT_END
1945 #define GST_CAT_LOG(args...)                            G_STMT_START{ }G_STMT_END
1946 #define GST_CAT_FIXME(args...)                          G_STMT_START{ }G_STMT_END
1947 #define GST_CAT_TRACE(args...)                          G_STMT_START{ }G_STMT_END
1948
1949 #define GST_ERROR_OBJECT(args...)                       G_STMT_START{ }G_STMT_END
1950 #define GST_WARNING_OBJECT(args...)                     G_STMT_START{ }G_STMT_END
1951 #define GST_INFO_OBJECT(args...)                        G_STMT_START{ }G_STMT_END
1952 #define GST_DEBUG_OBJECT(args...)                       G_STMT_START{ }G_STMT_END
1953 #define GST_LOG_OBJECT(args...)                         G_STMT_START{ }G_STMT_END
1954 #define GST_FIXME_OBJECT(args...)                       G_STMT_START{ }G_STMT_END
1955 #define GST_TRACE_OBJECT(args...)                       G_STMT_START{ }G_STMT_END
1956
1957 #define GST_ERROR_ID(args...)                   G_STMT_START{ }G_STMT_END
1958 #define GST_WARNING_ID(args...)                 G_STMT_START{ }G_STMT_END
1959 #define GST_INFO_ID(args...)                    G_STMT_START{ }G_STMT_END
1960 #define GST_DEBUG_ID(args...)                   G_STMT_START{ }G_STMT_END
1961 #define GST_LOG_ID(args...)                     G_STMT_START{ }G_STMT_END
1962 #define GST_FIXME_ID(args...)                   G_STMT_START{ }G_STMT_END
1963 #define GST_TRACE_ID(args...)                   G_STMT_START{ }G_STMT_END
1964
1965 #define GST_ERROR(args...)                              G_STMT_START{ }G_STMT_END
1966 #define GST_WARNING(args...)                            G_STMT_START{ }G_STMT_END
1967 #define GST_INFO(args...)                               G_STMT_START{ }G_STMT_END
1968 #define GST_DEBUG(args...)                              G_STMT_START{ }G_STMT_END
1969 #define GST_LOG(args...)                                G_STMT_START{ }G_STMT_END
1970 #define GST_FIXME(args...)                              G_STMT_START{ }G_STMT_END
1971 #define GST_TRACE(args...)                              G_STMT_START{ }G_STMT_END
1972
1973 #else /* !G_HAVE_GNUC_VARARGS */
1974 static inline void
1975 GST_CAT_LEVEL_LOG_valist (GstDebugCategory * cat,
1976     GstDebugLevel level, gpointer object, const char *format, va_list varargs)
1977 {
1978 }
1979
1980 static inline void
1981 GST_CAT_ERROR_OBJECT (GstDebugCategory * cat, gpointer obj, const char *format,
1982     ...)
1983 {
1984 }
1985
1986 static inline void
1987 GST_CAT_WARNING_OBJECT (GstDebugCategory * cat, gpointer obj,
1988     const char *format, ...)
1989 {
1990 }
1991
1992 static inline void
1993 GST_CAT_INFO_OBJECT (GstDebugCategory * cat, gpointer obj, const char *format,
1994     ...)
1995 {
1996 }
1997
1998 static inline void
1999 GST_CAT_DEBUG_OBJECT (GstDebugCategory * cat, gpointer obj, const char *format,
2000     ...)
2001 {
2002 }
2003
2004 static inline void
2005 GST_CAT_LOG_OBJECT (GstDebugCategory * cat, gpointer obj, const char *format,
2006     ...)
2007 {
2008 }
2009
2010 static inline void
2011 GST_CAT_FIXME_OBJECT (GstDebugCategory * cat, gpointer obj, const char *format,
2012     ...)
2013 {
2014 }
2015
2016 static inline void
2017 GST_CAT_TRACE_OBJECT (GstDebugCategory * cat, gpointer obj, const char *format,
2018     ...)
2019 {
2020 }
2021
2022 static inline void
2023 GST_CAT_ERROR (GstDebugCategory * cat, const char *format, ...)
2024 {
2025 }
2026
2027 static inline void
2028 GST_CAT_WARNING (GstDebugCategory * cat, const char *format, ...)
2029 {
2030 }
2031
2032 static inline void
2033 GST_CAT_INFO (GstDebugCategory * cat, const char *format, ...)
2034 {
2035 }
2036
2037 static inline void
2038 GST_CAT_DEBUG (GstDebugCategory * cat, const char *format, ...)
2039 {
2040 }
2041
2042 static inline void
2043 GST_CAT_LOG (GstDebugCategory * cat, const char *format, ...)
2044 {
2045 }
2046
2047 static inline void
2048 GST_CAT_FIXME (GstDebugCategory * cat, const char *format, ...)
2049 {
2050 }
2051
2052 static inline void
2053 GST_CAT_TRACE (GstDebugCategory * cat, const char *format, ...)
2054 {
2055 }
2056
2057 static inline void
2058 GST_ERROR_OBJECT (gpointer obj, const char *format, ...)
2059 {
2060 }
2061
2062 static inline void
2063 GST_WARNING_OBJECT (gpointer obj, const char *format, ...)
2064 {
2065 }
2066
2067 static inline void
2068 GST_INFO_OBJECT (gpointer obj, const char *format, ...)
2069 {
2070 }
2071
2072 static inline void
2073 GST_DEBUG_OBJECT (gpointer obj, const char *format, ...)
2074 {
2075 }
2076
2077 static inline void
2078 GST_LOG_OBJECT (gpointer obj, const char *format, ...)
2079 {
2080 }
2081
2082 static inline void
2083 GST_FIXME_OBJECT (gpointer obj, const char *format, ...)
2084 {
2085 }
2086
2087 static inline void
2088 GST_TRACE_OBJECT (gpointer obj, const char *format, ...)
2089 {
2090 }
2091
2092 static inline void
2093 GST_ERROR (const char *format, ...)
2094 {
2095 }
2096
2097 static inline void
2098 GST_WARNING (const char *format, ...)
2099 {
2100 }
2101
2102 static inline void
2103 GST_INFO (const char *format, ...)
2104 {
2105 }
2106
2107 static inline void
2108 GST_DEBUG (const char *format, ...)
2109 {
2110 }
2111
2112 static inline void
2113 GST_LOG (const char *format, ...)
2114 {
2115 }
2116
2117 static inline void
2118 GST_FIXME (const char *format, ...)
2119 {
2120 }
2121
2122 static inline void
2123 GST_TRACE (const char *format, ...)
2124 {
2125 }
2126
2127 #endif /* G_HAVE_GNUC_VARARGS */
2128 #endif /* G_HAVE_ISO_VARARGS */
2129
2130 #define GST_DEBUG_REGISTER_FUNCPTR(ptr) G_STMT_START{ }G_STMT_END
2131 #define GST_DEBUG_FUNCPTR(ptr) (ptr)
2132 #define GST_DEBUG_FUNCPTR_NAME(ptr) (g_strdup_printf ("%p", ptr))
2133
2134 #define GST_CAT_MEMDUMP_OBJECT(cat,obj,msg,data,length) G_STMT_START{ }G_STMT_END
2135 #define GST_CAT_MEMDUMP_ID(cat,id,msg,data,length)      G_STMT_START{ }G_STMT_END
2136 #define GST_CAT_MEMDUMP(cat,msg,data,length)            G_STMT_START{ }G_STMT_END
2137 #define GST_MEMDUMP_OBJECT(obj,msg,data,length)         G_STMT_START{ }G_STMT_END
2138 #define GST_MEMDUMP_ID(id,msg,data,length)              G_STMT_START{ }G_STMT_END
2139 #define GST_MEMDUMP(msg,data,length)                    G_STMT_START{ }G_STMT_END
2140
2141 #endif /* GST_DISABLE_GST_DEBUG */
2142
2143
2144 GST_API
2145 void gst_debug_print_stack_trace (void);
2146
2147 GST_API
2148 gchar * gst_debug_get_stack_trace (GstStackTraceFlags flags);
2149
2150 GST_API
2151 void                  gst_debug_add_ring_buffer_logger      (guint max_size_per_thread, guint thread_timeout);
2152 GST_API
2153 void                  gst_debug_remove_ring_buffer_logger   (void);
2154 GST_API
2155 gchar **              gst_debug_ring_buffer_logger_get_logs (void);
2156
2157 G_END_DECLS
2158
2159 #endif /* __GSTINFO_H__ */