Created
September 12, 2014 12:48
-
-
Save ensonic/1e96a3489136602fc1d7 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
From c85dac7bcc1ceec84751d3b1927428ece90cd52f Mon Sep 17 00:00:00 2001 | |
From: Stefan Sauer <ensonic@users.sf.net> | |
Date: Fri, 12 Sep 2014 14:42:23 +0200 | |
Subject: [PATCH] info: avoid global variable | |
Use user_data to pass the log_file handle to the logger-function. | |
RFC: when calling gst_debug_add_log_function(NULL, user_data, cleanup) | |
we will implicity use gst_debug_log_default() again, but now can't | |
ensure user_data. | |
--- | |
gst/gstinfo.c | 17 +++++++++-------- | |
1 file changed, 9 insertions(+), 8 deletions(-) | |
diff --git a/gst/gstinfo.c b/gst/gstinfo.c | |
index 3f56686..8eda545 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; | |
-- | |
2.1.0.rc2.206.gedb03e5 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment