gst/gstinfo.*: Change gst_debug_log(_valist) to take a const format string.

Original commit message from CVS:
2004-01-10  Benjamin Otte  <in7y118@public.uni-hamburg.de>

* gst/gstinfo.c: (gst_debug_log), (gst_debug_log_valist),
(gst_debug_message_get), (gst_debug_log_default):
* gst/gstinfo.h:
Change gst_debug_log(_valist) to take a const format string.
Change prototype of log function and functions using those to
take a GstDebugMessage instead of a string that requires using
gst_debug_message_get.
This commit is contained in:
Benjamin Otte 2004-01-10 01:49:00 +00:00
parent 67062b7320
commit 29e4f4c6ba
3 changed files with 50 additions and 12 deletions

View file

@ -1,3 +1,13 @@
2004-01-10 Benjamin Otte <in7y118@public.uni-hamburg.de>
* gst/gstinfo.c: (gst_debug_log), (gst_debug_log_valist),
(gst_debug_message_get), (gst_debug_log_default):
* gst/gstinfo.h:
Change gst_debug_log(_valist) to take a const format string.
Change prototype of log function and functions using those to
take a GstDebugMessage instead of a string that requires using
gst_debug_message_get.
2004-01-08 David Schleef <ds@schleef.org>
* Makefile.am:

View file

@ -71,6 +71,12 @@ static void gst_debug_reset_threshold (gpointer category,
gpointer unused);
static void gst_debug_reset_all_thresholds (void);
struct _GstDebugMessage {
gchar * message;
const gchar * format;
va_list arguments;
};
/* list of all name/level pairs from --gst-debug and GST_DEBUG */
static GStaticMutex __level_name_mutex = G_STATIC_MUTEX_INIT;
static GSList *__level_name = NULL;
@ -253,7 +259,7 @@ void _gst_debug_init (void)
*/
void gst_debug_log (GstDebugCategory *category, GstDebugLevel level,
const gchar *file, const gchar *function, gint line,
GObject *object, gchar *format, ...)
GObject *object, const gchar *format, ...)
{
va_list var_args;
@ -276,9 +282,9 @@ void gst_debug_log (GstDebugCategory *category, GstDebugLevel level,
*/
void gst_debug_log_valist (GstDebugCategory *category, GstDebugLevel level,
const gchar *file, const gchar *function, gint line,
GObject *object, gchar *format, va_list args)
GObject *object, const gchar *format, va_list args)
{
gchar *message;
GstDebugMessage message;
LogFuncEntry *entry;
GSList *handler;
@ -287,15 +293,34 @@ void gst_debug_log_valist (GstDebugCategory *category, GstDebugLevel level,
g_return_if_fail (function != NULL);
g_return_if_fail (format != NULL);
message = g_strdup_vprintf (format, args);
message.message = NULL;
message.format = format;
message.arguments = args;
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);
entry->func (category, level, file, function, line, object, &message, entry->user_data);
}
g_free (message);
g_free (message.message);
}
/**
* gst_debug_message_get:
* @message: a debug message
*
* Gets the string representation of a GstDebugMessage. This function is used
* in debug handlers to extract the message.
*/
const gchar *
gst_debug_message_get (GstDebugMessage *message)
{
if (message->message == NULL) {
message->message = g_strdup_vprintf (message->format, message->arguments);
}
return message->message;
}
/**
* gst_debug_construct_term_color:
* @colorinfo: the color info
@ -353,7 +378,7 @@ gst_debug_construct_term_color (guint colorinfo)
void
gst_debug_log_default (GstDebugCategory *category, GstDebugLevel level,
const gchar *file, const gchar *function, gint line,
GObject *object, gchar *message, gpointer unused)
GObject *object, GstDebugMessage *message, gpointer unused)
{
gchar *color;
gchar *clear;
@ -392,7 +417,7 @@ gst_debug_log_default (GstDebugCategory *category, GstDebugLevel level,
color, gst_debug_category_get_name (category), clear,
pidcolor, pid, clear,
color, file, line, function, obj, clear,
message);
gst_debug_message_get (message));
g_free (color);
g_free (pidcolor);

View file

@ -129,13 +129,14 @@ struct _GstDebugCategory {
#endif
#endif /* ifndef GST_FUNCTION */
typedef struct _GstDebugMessage GstDebugMessage;
typedef void (*GstLogFunction) (GstDebugCategory * category,
GstDebugLevel level,
const gchar * file,
const gchar * function,
gint line,
GObject * object,
gchar * message,
GstDebugMessage * message,
gpointer data);
/* Disable this subsystem if no varargs macro can be found.
@ -160,7 +161,7 @@ void gst_debug_log (GstDebugCategory * category,
const gchar * function,
gint line,
GObject * object,
gchar * format,
const gchar * format,
...) G_GNUC_PRINTF (7, 8) G_GNUC_NO_INSTRUMENT;
void gst_debug_log_valist (GstDebugCategory * category,
GstDebugLevel level,
@ -168,16 +169,18 @@ void gst_debug_log_valist (GstDebugCategory * category,
const gchar * function,
gint line,
GObject * object,
gchar * format,
const gchar * format,
va_list args) G_GNUC_NO_INSTRUMENT;
const gchar * gst_debug_message_get (GstDebugMessage * message);
void gst_debug_log_default (GstDebugCategory * category,
GstDebugLevel level,
const gchar * file,
const gchar * function,
gint line,
GObject * object,
gchar * message,
GstDebugMessage * message,
gpointer unused) G_GNUC_NO_INSTRUMENT;
G_CONST_RETURN gchar *