mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-01-11 01:45:33 +00:00
gstinfo: Add gst_debug_log_literal() function
This takes a plain message string and not a format string, and as a result doesn't have to be passed through vasprintf() and lead to further unnecessary allocations. It can also contain literal `%` because of that. The new function is mostly useful for bindings that would have to pass a full string to GStreamer anyway and would do formatting themselves with language-specific functionality. Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/1356>
This commit is contained in:
parent
a87be69ce5
commit
5dc95e00fa
2 changed files with 66 additions and 1 deletions
|
@ -578,6 +578,54 @@ gst_debug_log_valist (GstDebugCategory * category, GstDebugLevel level,
|
||||||
va_end (message.arguments);
|
va_end (message.arguments);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* gst_debug_log_literal:
|
||||||
|
* @category: category to log
|
||||||
|
* @level: level of the message is in
|
||||||
|
* @file: the file that emitted the message, usually the __FILE__ identifier
|
||||||
|
* @function: the function that emitted the message
|
||||||
|
* @line: the line from that the message was emitted, usually __LINE__
|
||||||
|
* @object: (transfer none) (allow-none): the object this message relates to,
|
||||||
|
* or %NULL if none
|
||||||
|
* @message_string: a message string
|
||||||
|
*
|
||||||
|
* Logs the given message using the currently registered debugging handlers.
|
||||||
|
*
|
||||||
|
* Since: 1.20
|
||||||
|
*/
|
||||||
|
void
|
||||||
|
gst_debug_log_literal (GstDebugCategory * category, GstDebugLevel level,
|
||||||
|
const gchar * file, const gchar * function, gint line,
|
||||||
|
GObject * object, const gchar * message_string)
|
||||||
|
{
|
||||||
|
GstDebugMessage message;
|
||||||
|
LogFuncEntry *entry;
|
||||||
|
GSList *handler;
|
||||||
|
|
||||||
|
g_return_if_fail (category != NULL);
|
||||||
|
|
||||||
|
#ifdef GST_ENABLE_EXTRA_CHECKS
|
||||||
|
g_warn_if_fail (object == NULL || G_IS_OBJECT (object));
|
||||||
|
#endif
|
||||||
|
|
||||||
|
if (level > gst_debug_category_get_threshold (category))
|
||||||
|
return;
|
||||||
|
|
||||||
|
g_return_if_fail (file != NULL);
|
||||||
|
g_return_if_fail (function != NULL);
|
||||||
|
g_return_if_fail (message_string != NULL);
|
||||||
|
|
||||||
|
message.message = (gchar *) message_string;
|
||||||
|
|
||||||
|
handler = __log_functions;
|
||||||
|
while (handler) {
|
||||||
|
entry = handler->data;
|
||||||
|
handler = g_slist_next (handler);
|
||||||
|
entry->func (category, level, file, function, line, object, &message,
|
||||||
|
entry->user_data);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* gst_debug_message_get:
|
* gst_debug_message_get:
|
||||||
* @message: a debug message
|
* @message: a debug message
|
||||||
|
@ -2341,6 +2389,13 @@ gst_debug_log_valist (GstDebugCategory * category, GstDebugLevel level,
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
gst_debug_log_literal (GstDebugCategory * category, GstDebugLevel level,
|
||||||
|
const gchar * file, const gchar * function, gint line,
|
||||||
|
GObject * object, const gchar * message_string)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
const gchar *
|
const gchar *
|
||||||
gst_debug_message_get (GstDebugMessage * message)
|
gst_debug_message_get (GstDebugMessage * message)
|
||||||
{
|
{
|
||||||
|
|
|
@ -368,11 +368,20 @@ void gst_debug_log_valist (GstDebugCategory * category,
|
||||||
GstDebugLevel level,
|
GstDebugLevel level,
|
||||||
const gchar * file,
|
const gchar * file,
|
||||||
const gchar * function,
|
const gchar * function,
|
||||||
gint line,
|
gint line,
|
||||||
GObject * object,
|
GObject * object,
|
||||||
const gchar * format,
|
const gchar * format,
|
||||||
va_list args) G_GNUC_NO_INSTRUMENT;
|
va_list args) G_GNUC_NO_INSTRUMENT;
|
||||||
|
|
||||||
|
GST_API
|
||||||
|
void gst_debug_log_literal (GstDebugCategory * category,
|
||||||
|
GstDebugLevel level,
|
||||||
|
const gchar * file,
|
||||||
|
const gchar * function,
|
||||||
|
gint line,
|
||||||
|
GObject * object,
|
||||||
|
const gchar * message_string) G_GNUC_NO_INSTRUMENT;
|
||||||
|
|
||||||
/* do not use this function, use the GST_DEBUG_CATEGORY_INIT macro */
|
/* do not use this function, use the GST_DEBUG_CATEGORY_INIT macro */
|
||||||
|
|
||||||
GST_API
|
GST_API
|
||||||
|
@ -1496,6 +1505,7 @@ GST_TRACE (const char *format, ...)
|
||||||
#if defined(__GNUC__) && __GNUC__ >= 3
|
#if defined(__GNUC__) && __GNUC__ >= 3
|
||||||
# pragma GCC poison gst_debug_log
|
# pragma GCC poison gst_debug_log
|
||||||
# pragma GCC poison gst_debug_log_valist
|
# pragma GCC poison gst_debug_log_valist
|
||||||
|
# pragma GCC poison gst_debug_log_literal
|
||||||
# pragma GCC poison _gst_debug_category_new
|
# pragma GCC poison _gst_debug_category_new
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue