-Subproject commit 098c0d7432be323d631b95b5d35f6f0840bf21bd
+Subproject commit 04c7a1ec1b9ced0b4359b3bbb2d8dc87bc7642c8
gst_debug_set_active
gst_debug_is_active
gst_debug_set_colored
+gst_debug_set_color_mode
+gst_debug_set_color_mode_from_string
gst_debug_is_colored
+gst_debug_get_color_mode
gst_debug_set_default_threshold
gst_debug_set_threshold_from_string
gst_debug_get_default_threshold
<para>
Set this environment variable to any value ("1" typically) to switch off
colouring in GST_DEBUG output. This has the same effect as specifying the
-<option>--gst-debug-no-color</option> command line option to well-behaved
-GStreamer applications (ie. those that pass command-line options correctly to
-GStreamer).
+<option>--gst-debug-no-color</option> or
+<option>--gst-debug-color-mode</option>=off command line option to
+well-behaved GStreamer applications (ie. those that pass command-line
+options correctly to GStreamer).
This is particularly useful to reduce the size of debug output and also allows
for the output to be compressed much better than with colours turned on.
</para>
+ <para>
+Has the same effect as setting GST_DEBUG_COLOR_MODE environment variable to
+"off".
+ </para>
+
+</formalpara>
+
+<formalpara id="GST_DEBUG_COLOR_MODE">
+ <title><envar>GST_DEBUG_COLOR_MODE</envar></title>
+
+ <para>
+Set this environment variable to change log colouring in GST_DEBUG output.
+Possible values:
+ <variablelist>
+
+ <varlistentry>
+ <term><option>on</option></term>
+ <listitem>
+ <para>
+Enables debug log output coloring. Uses default coloring method for current
+platform. This is the default.
+ </para>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry>
+ <term><option>off</option></term>
+ <listitem>
+ <para>
+Disables debug log output coloring. This has the same effect as specifying the
+<option>--gst-debug-color-mode</option>=off command line option to
+well-behaved GStreamer applications (ie. those that pass command-line
+options correctly to GStreamer).
+This is particularly useful to reduce the size of debug output and also allows
+for the output to be compressed much better than with colours turned on.
+ </para>
+ <para>
+Has the same effect as setting GST_DEBUG_NO_COLOR environment variable to
+any value.
+ </para>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry>
+ <term><option>auto</option></term>
+ <listitem>
+ <para>
+Same as <option>on</option>.
+ </para>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry>
+ <term><option>disable</option></term>
+ <listitem>
+ <para>
+Same as <option>off</option>.
+ </para>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry>
+ <term><option>unix</option></term>
+ <listitem>
+ <para>
+Enables debug log output coloring and forces the use of UNIX termial codes
+for coloring, even if this method is not normally used on current platform.
+This has the same effect as specifying the
+<option>--gst-debug-color-mode</option>=unix command line option to
+well-behaved GStreamer applications (ie. those that pass command-line options
+correctly to GStreamer).
+This is particularly useful to dump debug output into a file on non-UNIX
+platforms to be sent to developers who have viewers that support UNIX terminal
+codes.
+ </para>
+ </listitem>
+ </varlistentry>
+
+ </variablelist>
+ </para>
</formalpara>
</listitem>
<listitem>
<para>
+ <option>--gst-debug-color-mode=<replaceable>MODE</replaceable></option>
+ will change debug log coloring mode. <replaceable>MODE</replaceable>
+ can be one of the following: <option>on</option>,
+ <option>off</option>, <option>auto</option>,
+ <option>disable</option>, <option>unix</option>.
+ You can also set the GST_DEBUG_COLOR_MODE environment variable
+ if you want to change colored debug output permanently. Note that
+ if you are disabling color purely to avoid messing up your pager
+ output, try using <command>less -R</command>.
+ </para>
+ </listitem>
+ <listitem>
+ <para>
<option>--gst-debug-disable</option> disables debugging altogether.
</para>
</listitem>
ARG_DEBUG,
ARG_DEBUG_DISABLE,
ARG_DEBUG_NO_COLOR,
+ ARG_DEBUG_COLOR_MODE,
ARG_DEBUG_HELP,
#endif
ARG_PLUGIN_SPEW,
{"gst-debug-no-color", 0, G_OPTION_FLAG_NO_ARG, G_OPTION_ARG_CALLBACK,
(gpointer) parse_goption_arg, N_("Disable colored debugging output"),
NULL},
+ {"gst-debug-color-mode", 0, 0, G_OPTION_ARG_CALLBACK,
+ (gpointer) parse_goption_arg,
+ N_("Changes coloring mode of the debug log. "
+ "Possible modes: off, on, disable, auto, unix"),
+ NULL},
{"gst-debug-disable", 0, G_OPTION_FLAG_NO_ARG, G_OPTION_ARG_CALLBACK,
(gpointer) parse_goption_arg, N_("Disable debugging"), NULL},
#endif
#ifndef GST_DISABLE_GST_DEBUG
{
const gchar *debug_list;
+ const gchar *color_mode;
if (g_getenv ("GST_DEBUG_NO_COLOR") != NULL)
- gst_debug_set_colored (FALSE);
+ gst_debug_set_color_mode (GST_DEBUG_COLOR_MODE_OFF);
+ color_mode = g_getenv ("GST_DEBUG_COLOR_MODE");
+ if (color_mode)
+ gst_debug_set_color_mode_from_string (color_mode);
debug_list = g_getenv ("GST_DEBUG");
if (debug_list) {
g_print ("---------------------+--------+--------------------------------\n");
while (walk) {
+ gboolean on_unix;
GstDebugCategory *cat = (GstDebugCategory *) walk->data;
+ GstDebugColorMode coloring = gst_debug_get_color_mode ();
+#ifdef G_OS_UNIX
+ on_unix = TRUE;
+#else
+ on_unix = FALSE;
+#endif
+
+ if (GST_DEBUG_COLOR_MODE_UNIX == coloring
+ || (on_unix && GST_DEBUG_COLOR_MODE_ON == coloring)) {
+ gchar *color = gst_debug_construct_term_color (cat->color);
- if (gst_debug_is_colored ()) {
+ g_print ("%s%-20s\033[00m %1d %s %s%s\033[00m\n",
+ color,
+ gst_debug_category_get_name (cat),
+ gst_debug_category_get_threshold (cat),
+ gst_debug_level_get_name (gst_debug_category_get_threshold (cat)),
+ color, gst_debug_category_get_description (cat));
+ g_free (color);
+ } else if (GST_DEBUG_COLOR_MODE_ON == coloring && !on_unix) {
#ifdef G_OS_WIN32
gint color = gst_debug_construct_win_color (cat->color);
const gint clear = FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE;
g_print ("%s", gst_debug_category_get_description (cat));
SetConsoleTextAttribute (GetStdHandle (STD_OUTPUT_HANDLE), clear);
g_print ("\n");
-#else /* G_OS_WIN32 */
- gchar *color = gst_debug_construct_term_color (cat->color);
-
- g_print ("%s%-20s\033[00m %1d %s %s%s\033[00m\n",
- color,
- gst_debug_category_get_name (cat),
- gst_debug_category_get_threshold (cat),
- gst_debug_level_get_name (gst_debug_category_get_threshold (cat)),
- color, gst_debug_category_get_description (cat));
- g_free (color);
#endif /* G_OS_WIN32 */
} else {
g_print ("%-20s %1d %s %s\n", gst_debug_category_get_name (cat),
case ARG_DEBUG_NO_COLOR:
gst_debug_set_colored (FALSE);
break;
+ case ARG_DEBUG_COLOR_MODE:
+ gst_debug_set_color_mode_from_string (arg);
+ break;
case ARG_DEBUG_DISABLE:
gst_debug_set_active (FALSE);
break;
"--gst-debug", ARG_DEBUG}, {
"--gst-debug-disable", ARG_DEBUG_DISABLE}, {
"--gst-debug-no-color", ARG_DEBUG_NO_COLOR}, {
+ "--gst-debug-color-mode", ARG_DEBUG_COLOR_MODE}, {
"--gst-debug-help", ARG_DEBUG_HELP},
#endif
{
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 = 1;
+static volatile gint G_GNUC_MAY_ALIAS __use_color = GST_DEBUG_COLOR_MODE_ON;
static FILE *log_file;
#define CAT_FMT "%20s %s:%d:%s:%s"
#ifdef G_OS_WIN32
-static const guchar levelcolormap[GST_LEVEL_COUNT] = {
+static const guchar levelcolormap_w32[GST_LEVEL_COUNT] = {
/* GST_LEVEL_NONE */
FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE,
/* GST_LEVEL_ERROR */
FOREGROUND_BLUE, FOREGROUND_RED | FOREGROUND_BLUE,
FOREGROUND_GREEN | FOREGROUND_BLUE,
};
-#else
+#endif /* G_OS_WIN32 */
static const gchar *levelcolormap[GST_LEVEL_COUNT] = {
"\033[37m", /* GST_LEVEL_NONE */
"\033[31;01m", /* GST_LEVEL_ERROR */
"\033[37m", /* placeholder for log level 8 */
"\033[37m" /* GST_LEVEL_MEMDUMP */
};
-#endif
/**
* gst_debug_log_default:
gint pid;
GstClockTime elapsed;
gchar *obj = NULL;
- gboolean is_colored;
+ GstDebugColorMode color_mode;
if (level > gst_debug_category_get_threshold (category))
return;
pid = getpid ();
- is_colored = gst_debug_is_colored ();
+ color_mode = gst_debug_get_color_mode ();
if (object) {
obj = gst_debug_print_object (object);
elapsed = GST_CLOCK_DIFF (_priv_gst_info_start_time,
gst_util_get_timestamp ());
- if (is_colored) {
-#ifndef G_OS_WIN32
- /* colors, non-windows */
- gchar *color = NULL;
- const gchar *clear;
- gchar pidcolor[10];
- const gchar *levelcolor;
-
- color = gst_debug_construct_term_color (gst_debug_category_get_color
- (category));
- clear = "\033[00m";
- g_sprintf (pidcolor, "\033[3%1dm", pid % 6 + 31);
- levelcolor = levelcolormap[level];
-
-#define PRINT_FMT " %s"PID_FMT"%s "PTR_FMT" %s%s%s %s"CAT_FMT"%s %s\n"
- fprintf (log_file, "%" GST_TIME_FORMAT PRINT_FMT, GST_TIME_ARGS (elapsed),
- pidcolor, pid, clear, g_thread_self (), levelcolor,
- gst_debug_level_get_name (level), clear, color,
- gst_debug_category_get_name (category), file, line, function, obj,
- clear, gst_debug_message_get (message));
- fflush (log_file);
-#undef PRINT_FMT
- g_free (color);
-#else
- /* colors, windows. We take a lock to keep colors and content together.
+ if (color_mode != GST_DEBUG_COLOR_MODE_OFF) {
+#ifdef G_OS_WIN32
+ /* We take a lock to keep colors and content together.
* Maybe there is a better way but for now this will do the right
* thing. */
static GMutex win_print_mutex;
- const gint clear = FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE;
+ g_mutex_lock (&win_print_mutex);
+ if (color_mode == GST_DEBUG_COLOR_MODE_UNIX) {
+#endif
+ /* colors, non-windows */
+ gchar *color = NULL;
+ const gchar *clear;
+ gchar pidcolor[10];
+ const gchar *levelcolor;
+
+ color = gst_debug_construct_term_color (gst_debug_category_get_color
+ (category));
+ clear = "\033[00m";
+ g_sprintf (pidcolor, "\033[3%1dm", pid % 6 + 31);
+ levelcolor = levelcolormap[level];
+
+#define PRINT_FMT " %s"PID_FMT"%s "PTR_FMT" %s%s%s %s"CAT_FMT"%s %s\n"
+ fprintf (log_file, "%" GST_TIME_FORMAT PRINT_FMT, GST_TIME_ARGS (elapsed),
+ pidcolor, pid, clear, g_thread_self (), levelcolor,
+ gst_debug_level_get_name (level), clear, color,
+ gst_debug_category_get_name (category), file, line, function, obj,
+ clear, gst_debug_message_get (message));
+ fflush (log_file);
+#undef PRINT_FMT
+ g_free (color);
+#ifdef G_OS_WIN32
+ } else {
+ /* colors, windows. */
+ const gint clear = FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE;
#define SET_COLOR(c) G_STMT_START { \
if (log_file == stderr) \
SetConsoleTextAttribute (GetStdHandle (STD_ERROR_HANDLE), (c)); \
} G_STMT_END
- g_mutex_lock (&win_print_mutex);
- /* timestamp */
- fprintf (log_file, "%" GST_TIME_FORMAT " ", GST_TIME_ARGS (elapsed));
- fflush (log_file);
- /* pid */
- SET_COLOR (available_colors[pid % G_N_ELEMENTS (available_colors)]);
- fprintf (log_file, PID_FMT, pid);
- fflush (log_file);
- /* thread */
- SET_COLOR (clear);
- fprintf (log_file, " " PTR_FMT " ", g_thread_self ());
- fflush (log_file);
- /* level */
- SET_COLOR (levelcolormap[level]);
- fprintf (log_file, "%s ", gst_debug_level_get_name (level));
- fflush (log_file);
- /* category */
- SET_COLOR (gst_debug_construct_win_color (gst_debug_category_get_color
- (category)));
- fprintf (log_file, CAT_FMT, gst_debug_category_get_name (category),
- file, line, function, obj);
- fflush (log_file);
- /* message */
- SET_COLOR (clear);
- fprintf (log_file, " %s\n", gst_debug_message_get (message));
- fflush (log_file);
+ /* timestamp */
+ fprintf (log_file, "%" GST_TIME_FORMAT " ", GST_TIME_ARGS (elapsed));
+ fflush (log_file);
+ /* pid */
+ SET_COLOR (available_colors[pid % G_N_ELEMENTS (available_colors)]);
+ fprintf (log_file, PID_FMT, pid);
+ fflush (log_file);
+ /* thread */
+ SET_COLOR (clear);
+ fprintf (log_file, " " PTR_FMT " ", g_thread_self ());
+ fflush (log_file);
+ /* level */
+ SET_COLOR (levelcolormap_w32[level]);
+ fprintf (log_file, "%s ", gst_debug_level_get_name (level));
+ fflush (log_file);
+ /* category */
+ SET_COLOR (gst_debug_construct_win_color (gst_debug_category_get_color
+ (category)));
+ fprintf (log_file, CAT_FMT, gst_debug_category_get_name (category),
+ file, line, function, obj);
+ fflush (log_file);
+ /* message */
+ SET_COLOR (clear);
+ fprintf (log_file, " %s\n", gst_debug_message_get (message));
+ fflush (log_file);
+ }
g_mutex_unlock (&win_print_mutex);
#endif
} else {
* @colored: Whether to use colored output or not
*
* Sets or unsets the use of coloured debugging output.
+ * Same as gst_debug_set_color_mode () with the argument being
+ * being GST_DEBUG_COLOR_MODE_ON or GST_DEBUG_COLOR_MODE_OFF.
*
* This function may be called before gst_init().
*/
void
gst_debug_set_colored (gboolean colored)
{
- g_atomic_int_set (&__use_color, (gint) colored);
+ GstDebugColorMode new_mode;
+ new_mode = colored ? GST_DEBUG_COLOR_MODE_ON : GST_DEBUG_COLOR_MODE_OFF;
+ g_atomic_int_set (&__use_color, (gint) new_mode);
+}
+
+/**
+ * gst_debug_set_color_mode:
+ * @mode: The coloring mode for debug output. See @GstDebugColorMode.
+ *
+ * Changes the coloring mode for debug output.
+ *
+ * This function may be called before gst_init().
+ */
+void
+gst_debug_set_color_mode (GstDebugColorMode mode)
+{
+ g_atomic_int_set (&__use_color, mode);
+}
+
+/**
+ * gst_debug_set_color_mode_from_string:
+ * @mode: The coloring mode for debug output. One of the following:
+ * "on", "auto", "off", "disable", "unix".
+ *
+ * Changes the coloring mode for debug output.
+ *
+ * This function may be called before gst_init().
+ */
+void
+gst_debug_set_color_mode_from_string (const gchar * str)
+{
+ if ((strcmp (str, "on") == 0) || (strcmp (str, "auto") == 0))
+ gst_debug_set_color_mode (GST_DEBUG_COLOR_MODE_ON);
+ else if ((strcmp (str, "off") == 0) || (strcmp (str, "disable") == 0))
+ gst_debug_set_color_mode (GST_DEBUG_COLOR_MODE_OFF);
+ else if (strcmp (str, "unix") == 0)
+ gst_debug_set_color_mode (GST_DEBUG_COLOR_MODE_UNIX);
}
/**
gboolean
gst_debug_is_colored (void)
{
- return (gboolean) g_atomic_int_get (&__use_color);
+ GstDebugColorMode mode = g_atomic_int_get (&__use_color);
+ return (mode == GST_DEBUG_COLOR_MODE_UNIX || mode == GST_DEBUG_COLOR_MODE_ON);
+}
+
+/**
+ * gst_debug_get_color_mode:
+ *
+ * Changes the coloring mode for debug output.
+ *
+ * Returns: see @GstDebugColorMode for possible values.
+ */
+GstDebugColorMode
+gst_debug_get_color_mode (void)
+{
+ return g_atomic_int_get (&__use_color);
}
/**
{
}
+void
+gst_debug_set_color_mode (GstDebugColorMode mode)
+{
+}
+
+void
+gst_debug_set_color_mode_from_string (const gchar * str)
+{
+}
+
gboolean
gst_debug_is_colored (void)
{
return FALSE;
}
+GstDebugColorMode
+gst_debug_get_color_mode (void)
+{
+ return GST_DEBUG_COLOR_MODE_OFF;
+}
+
void
gst_debug_set_threshold_from_string (const gchar * list, gboolean reset)
{
GST_DEBUG_UNDERLINE = 0x0200
} GstDebugColorFlags;
+/**
+ * GstDebugColorMode:
+ * @GST_DEBUG_COLOR_MODE_OFF: Do not use colors in logs.
+ * @GST_DEBUG_COLOR_MODE_ON: Paint logs in a platform-specific way.
+ * @GST_DEBUG_COLOR_MODE_UNIX: Paint logs with UNIX terminal color codes
+ * no matter what platform GStreamer is running on.
+ */
+typedef enum {
+ GST_DEBUG_COLOR_MODE_OFF = 0,
+ GST_DEBUG_COLOR_MODE_ON = 1,
+ GST_DEBUG_COLOR_MODE_UNIX = 2
+} GstDebugColorMode;
+
+
#define GST_DEBUG_FG_MASK (0x000F)
#define GST_DEBUG_BG_MASK (0x00F0)
#define GST_DEBUG_FORMAT_MASK (0xFF00)
gboolean gst_debug_is_active (void);
void gst_debug_set_colored (gboolean colored);
+void gst_debug_set_color_mode (GstDebugColorMode mode);
+void gst_debug_set_color_mode_from_string (const gchar * str);
gboolean gst_debug_is_colored (void);
+GstDebugColorMode gst_debug_get_color_mode (void);
void gst_debug_set_default_threshold (GstDebugLevel level);
GstDebugLevel gst_debug_get_default_threshold (void);
#define gst_debug_set_active(active) G_STMT_START{ }G_STMT_END
#define gst_debug_is_active() (FALSE)
#define gst_debug_set_colored(colored) G_STMT_START{ }G_STMT_END
+#define gst_debug_set_color_mode(mode) G_STMT_START{ }G_STMT_END
+#define gst_debug_set_color_mode_from_string(mode) G_STMT_START{ }G_STMT_END
#define gst_debug_is_colored() (FALSE)
+#define gst_debug_get_color_mode() (GST_DEBUG_COLOR_MODE_OFF)
#define gst_debug_set_default_threshold(level) G_STMT_START{ }G_STMT_END
#define gst_debug_get_default_threshold() (GST_LEVEL_NONE)
#define gst_debug_set_threshold_for_name(name,level) G_STMT_START{ }G_STMT_END
to print messages without color. Setting the \fBGST_DEBUG_NO_COLOR\fR
environment variable will achieve the same thing.
.TP 8
+.B \-\-gst\-debug\-color\-mode
+\fIGStreamer\fP normally prints debugging messages so that the
+messages are color-coded when printed to a terminal that handles
+ANSI escape sequences (on *nix), or uses W32 console API to color the
+messages printed into a console (on W32). Using this option causes
+\fIGStreamer\fP to print messages without color ('off' or 'disable'),
+print messages with default colors ('on' or 'auto'), or print messages
+using ANSI escape sequences for coloring ('unix'). Setting the
+\fBGST_DEBUG_COLOR_MODE\fR environment variable will achieve the same thing.
+.TP 8
.B \-\-gst\-debug\-disable
Disables debugging.
.TP 8
#
# based on plot-timeline.py by Federico Mena-Quintero <federico at ximian dotcom>
# example:
-# GST_DEBUG_NO_COLOR=1 GST_DEBUG="*:3" gst-launch-1.0 2>debug.log audiotestsrc num-buffers=10 ! audioconvert ! alsasink
+# GST_DEBUG_COLOR_MODE=off GST_DEBUG="*:3" gst-launch-1.0 2>debug.log audiotestsrc num-buffers=10 ! audioconvert ! alsasink
# gst-plot-timeline.py debug.log --output=debug.png
import math
return 1
if len(args) != 1:
- print 'Please specify only one input filename, which is an debug log taken with "GST_DEBUG_NO_COLOR=1 GST_DEBUG=XXX <application>"'
+ print 'Please specify only one input filename, which is an debug log taken with "GST_DEBUG_COLOR_MODE=off GST_DEBUG=XXX <application>"'
return 1
in_filename = args[0]
gst_debug_remove_log_function_by_data
gst_debug_set_active
gst_debug_set_colored
+ gst_debug_set_color_mode
+ gst_debug_get_color_mode
+ gst_debug_set_color_mode_from_string
gst_debug_set_default_threshold
gst_debug_set_threshold_for_name
gst_debug_set_threshold_from_string