summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStefan Sauer <ensonic@users.sf.net>2014-09-12 14:42:23 +0200
committerStefan Sauer <ensonic@users.sf.net>2014-09-17 09:47:36 +0200
commita528dadb9800fd3b21b60c4b3cd707e4616aed41 (patch)
tree6b0767d4216c98d65b7ffda6c0d2923b413afa3c
parent343007894e4c4f5d320105eaa4c932896b763787 (diff)
info: avoid global variable for log_file
Use user_data to pass the log_file handle to the logger-function. If one wants to change the log target (e.g. GST_DEBUG_FILE), simply call gst_debug_remove_log_function() and re-add the handler with the new log-target using gst_debug_add_log_function ().
-rw-r--r--gst/gstinfo.c17
1 files changed, 9 insertions, 8 deletions
diff --git a/gst/gstinfo.c b/gst/gstinfo.c
index 3f566866aa..8eda545543 100644
--- a/gst/gstinfo.c
+++ b/gst/gstinfo.c
@@ -264,8 +264,6 @@ static gboolean pretty_tags = PRETTY_TAGS_DEFAULT;
static volatile gint G_GNUC_MAY_ALIAS __default_level = GST_LEVEL_DEFAULT;
static volatile gint G_GNUC_MAY_ALIAS __use_color = GST_DEBUG_COLOR_MODE_ON;
-static FILE *log_file;
-
/* FIXME: export this? */
gboolean
_priv_gst_in_valgrind (void)
@@ -304,6 +302,7 @@ void
_priv_gst_debug_init (void)
{
const gchar *env;
+ FILE *log_file;
env = g_getenv ("GST_DEBUG_FILE");
if (env != NULL && *env != '\0') {
@@ -333,7 +332,7 @@ _priv_gst_debug_init (void)
_GST_CAT_DEBUG = _gst_debug_category_new ("GST_DEBUG",
GST_DEBUG_BOLD | GST_DEBUG_FG_YELLOW, "debugging subsystem");
- gst_debug_add_log_function (gst_debug_log_default, NULL, NULL);
+ gst_debug_add_log_function (gst_debug_log_default, log_file, NULL);
/* FIXME: add descriptions here */
GST_CAT_GST_INIT = _gst_debug_category_new ("GST_INIT",
@@ -962,12 +961,13 @@ static const gchar *levelcolormap[GST_LEVEL_COUNT] = {
* @message: the actual message
* @object: (transfer none) (allow-none): the object this message relates to,
* or %NULL if none
- * @unused: an unused variable, reserved for some user_data.
+ * @user_data: the FILE* to log to
*
* The default logging handler used by GStreamer. Logging functions get called
- * whenever a macro like GST_DEBUG or similar is used. This function outputs the
- * message and additional info to stderr (or the log file specified via the
- * GST_DEBUG_FILE environment variable).
+ * whenever a macro like GST_DEBUG or similar is used. By default this function
+ * is setup to output the message and additional info to stderr (or the log file
+ * specified via the GST_DEBUG_FILE environment variable) as received via
+ * @user_data.
*
* You can add other handlers by using gst_debug_add_log_function().
* And you can remove this handler by calling
@@ -976,12 +976,13 @@ static const gchar *levelcolormap[GST_LEVEL_COUNT] = {
void
gst_debug_log_default (GstDebugCategory * category, GstDebugLevel level,
const gchar * file, const gchar * function, gint line,
- GObject * object, GstDebugMessage * message, gpointer unused)
+ GObject * object, GstDebugMessage * message, gpointer user_data)
{
gint pid;
GstClockTime elapsed;
gchar *obj = NULL;
GstDebugColorMode color_mode;
+ FILE *log_file = user_data ? user_data : stderr;
if (level > gst_debug_category_get_threshold (category))
return;