Commit 66d2bae6 authored by Tim-Philipp Müller's avatar Tim-Philipp Müller 🐠

Add gst_print(), gst_println(), gst_printerr(), gst_printerrln()

Useful for debugging.

https://bugzilla.gnome.org/show_bug.cgi?id=766470
parent 584da6e8
......@@ -1392,6 +1392,10 @@ gst_debug_bin_to_dot_file_with_ts
gst_info_vasprintf
gst_info_strdup_vprintf
gst_info_strdup_printf
gst_print
gst_println
gst_printerr
gst_printerrln
<SUBSECTION Standard>
GST_TYPE_DEBUG_COLOR_FLAGS
GST_TYPE_DEBUG_COLOR_MODE
......
......@@ -2438,7 +2438,7 @@ gst_info_strdup_vprintf (const gchar * format, va_list args)
* @format: a printf style format string
* @...: the printf arguments for @format
*
* Allocates, fills and returns a null terminated string from the printf style
* Allocates, fills and returns a 0-terminated string from the printf style
* @format string and corresponding arguments.
*
* See gst_info_vasprintf() for when this function is required.
......@@ -2462,6 +2462,146 @@ gst_info_strdup_printf (const gchar * format, ...)
return ret;
}
/**
* gst_print:
* @format: a printf style format string
* @...: the printf arguments for @format
*
* Outputs a formatted message via the GLib print handler. The default print
* handler simply outputs the message to stdout.
*
* This function will not append a new-line character at the end, unlike
* gst_println() which will.
*
* All strings must be in ASCII or UTF-8 encoding.
*
* This function differs from g_print() in that it supports all the additional
* printf specifiers that are supported by GStreamer's debug logging system,
* such as #GST_PTR_FORMAT and #GST_SEGMENT_FORMAT.
*
* This function is primarily for printing debug output.
*
* Since: 1.12
*/
void
gst_print (const gchar * format, ...)
{
va_list args;
gchar *str;
va_start (args, format);
str = gst_info_strdup_vprintf (format, args);
va_end (args);
g_print ("%s", str);
g_free (str);
}
/**
* gst_println:
* @format: a printf style format string
* @...: the printf arguments for @format
*
* Outputs a formatted message via the GLib print handler. The default print
* handler simply outputs the message to stdout.
*
* This function will append a new-line character at the end, unlike
* gst_print() which will not.
*
* All strings must be in ASCII or UTF-8 encoding.
*
* This function differs from g_print() in that it supports all the additional
* printf specifiers that are supported by GStreamer's debug logging system,
* such as #GST_PTR_FORMAT and #GST_SEGMENT_FORMAT.
*
* This function is primarily for printing debug output.
*
* Since: 1.12
*/
void
gst_println (const gchar * format, ...)
{
va_list args;
gchar *str;
va_start (args, format);
str = gst_info_strdup_vprintf (format, args);
va_end (args);
g_print ("%s\n", str);
g_free (str);
}
/**
* gst_printerr:
* @format: a printf style format string
* @...: the printf arguments for @format
*
* Outputs a formatted message via the GLib error message handler. The default
* handler simply outputs the message to stderr.
*
* This function will not append a new-line character at the end, unlike
* gst_printerrln() which will.
*
* All strings must be in ASCII or UTF-8 encoding.
*
* This function differs from g_printerr() in that it supports the additional
* printf specifiers that are supported by GStreamer's debug logging system,
* such as #GST_PTR_FORMAT and #GST_SEGMENT_FORMAT.
*
* This function is primarily for printing debug output.
*
* Since: 1.12
*/
void
gst_printerr (const gchar * format, ...)
{
va_list args;
gchar *str;
va_start (args, format);
str = gst_info_strdup_vprintf (format, args);
va_end (args);
g_printerr ("%s", str);
g_free (str);
}
/**
* gst_printerrln:
* @format: a printf style format string
* @...: the printf arguments for @format
*
* Outputs a formatted message via the GLib error message handler. The default
* handler simply outputs the message to stderr.
*
* This function will append a new-line character at the end, unlike
* gst_printerr() which will not.
*
* All strings must be in ASCII or UTF-8 encoding.
*
* This function differs from g_printerr() in that it supports the additional
* printf specifiers that are supported by GStreamer's debug logging system,
* such as #GST_PTR_FORMAT and #GST_SEGMENT_FORMAT.
*
* This function is primarily for printing debug output.
*
* Since: 1.12
*/
void
gst_printerrln (const gchar * format, ...)
{
va_list args;
gchar *str;
va_start (args, format);
str = gst_info_strdup_vprintf (format, args);
va_end (args);
g_printerr ("%s\n", str);
g_free (str);
}
#ifdef HAVE_UNWIND
#ifdef HAVE_DW
static gboolean
......
......@@ -413,6 +413,12 @@ gint gst_info_vasprintf (gchar ** result,
gchar * gst_info_strdup_vprintf (const gchar *format, va_list args) G_GNUC_PRINTF (1, 0);
gchar * gst_info_strdup_printf (const gchar *format, ...) G_GNUC_PRINTF (1, 2);
void gst_print (const gchar * format, ...) G_GNUC_PRINTF (1, 2);
void gst_println (const gchar * format, ...) G_GNUC_PRINTF (1, 2);
void gst_printerr (const gchar * format, ...) G_GNUC_PRINTF (1, 2);
void gst_printerrln (const gchar * format, ...) G_GNUC_PRINTF (1, 2);
#ifndef GST_DISABLE_GST_DEBUG
/* cast to void * avoids a warning with gcc 6
......
......@@ -1064,6 +1064,10 @@ EXPORTS
gst_preset_save_preset
gst_preset_set_app_dir
gst_preset_set_meta
gst_print
gst_printerr
gst_printerrln
gst_println
gst_progress_type_get_type
gst_protection_meta_api_get_type
gst_protection_meta_get_info
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment