info: Add debug color mode option

This allows to explicitely set the debug output color
mode to UNIX on every platform, enable it (use platform
default color mode) or enable it.

https://bugzilla.gnome.org/show_bug.cgi?id=674320
This commit is contained in:
Руслан Ижбулатов 2013-07-18 15:10:10 +04:00 committed by Sebastian Dröge
parent 46106ebe8f
commit 797fcd1d49
10 changed files with 302 additions and 78 deletions

2
common

@ -1 +1 @@
Subproject commit 098c0d7432be323d631b95b5d35f6f0840bf21bd Subproject commit 04c7a1ec1b9ced0b4359b3bbb2d8dc87bc7642c8

View file

@ -1224,7 +1224,10 @@ gst_debug_remove_log_function_by_data
gst_debug_set_active gst_debug_set_active
gst_debug_is_active gst_debug_is_active
gst_debug_set_colored gst_debug_set_colored
gst_debug_set_color_mode
gst_debug_set_color_mode_from_string
gst_debug_is_colored gst_debug_is_colored
gst_debug_get_color_mode
gst_debug_set_default_threshold gst_debug_set_default_threshold
gst_debug_set_threshold_from_string gst_debug_set_threshold_from_string
gst_debug_get_default_threshold gst_debug_get_default_threshold

View file

@ -237,12 +237,93 @@ e.g. GST_DEBUG=*:WARNING,*audio*:LOG
<para> <para>
Set this environment variable to any value ("1" typically) to switch off 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 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 <option>--gst-debug-no-color</option> or
GStreamer applications (ie. those that pass command-line options correctly to <option>--gst-debug-color-mode</option>=off command line option to
GStreamer). 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 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. for the output to be compressed much better than with colours turned on.
</para> </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> </formalpara>

View file

@ -112,6 +112,19 @@
output, try using <command>less -R</command>. output, try using <command>less -R</command>.
</para> </para>
</listitem> </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> <listitem>
<para> <para>
<option>--gst-debug-disable</option> disables debugging altogether. <option>--gst-debug-disable</option> disables debugging altogether.

View file

@ -176,6 +176,7 @@ enum
ARG_DEBUG, ARG_DEBUG,
ARG_DEBUG_DISABLE, ARG_DEBUG_DISABLE,
ARG_DEBUG_NO_COLOR, ARG_DEBUG_NO_COLOR,
ARG_DEBUG_COLOR_MODE,
ARG_DEBUG_HELP, ARG_DEBUG_HELP,
#endif #endif
ARG_PLUGIN_SPEW, ARG_PLUGIN_SPEW,
@ -250,6 +251,11 @@ gst_init_get_option_group (void)
{"gst-debug-no-color", 0, G_OPTION_FLAG_NO_ARG, G_OPTION_ARG_CALLBACK, {"gst-debug-no-color", 0, G_OPTION_FLAG_NO_ARG, G_OPTION_ARG_CALLBACK,
(gpointer) parse_goption_arg, N_("Disable colored debugging output"), (gpointer) parse_goption_arg, N_("Disable colored debugging output"),
NULL}, 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, {"gst-debug-disable", 0, G_OPTION_FLAG_NO_ARG, G_OPTION_ARG_CALLBACK,
(gpointer) parse_goption_arg, N_("Disable debugging"), NULL}, (gpointer) parse_goption_arg, N_("Disable debugging"), NULL},
#endif #endif
@ -475,9 +481,13 @@ init_pre (GOptionContext * context, GOptionGroup * group, gpointer data,
#ifndef GST_DISABLE_GST_DEBUG #ifndef GST_DISABLE_GST_DEBUG
{ {
const gchar *debug_list; const gchar *debug_list;
const gchar *color_mode;
if (g_getenv ("GST_DEBUG_NO_COLOR") != NULL) 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"); debug_list = g_getenv ("GST_DEBUG");
if (debug_list) { if (debug_list) {
@ -743,9 +753,27 @@ gst_debug_help (void)
g_print ("---------------------+--------+--------------------------------\n"); g_print ("---------------------+--------+--------------------------------\n");
while (walk) { while (walk) {
gboolean on_unix;
GstDebugCategory *cat = (GstDebugCategory *) walk->data; 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_is_colored ()) { if (GST_DEBUG_COLOR_MODE_UNIX == coloring
|| (on_unix && GST_DEBUG_COLOR_MODE_ON == coloring)) {
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);
} else if (GST_DEBUG_COLOR_MODE_ON == coloring && !on_unix) {
#ifdef G_OS_WIN32 #ifdef G_OS_WIN32
gint color = gst_debug_construct_win_color (cat->color); gint color = gst_debug_construct_win_color (cat->color);
const gint clear = FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE; const gint clear = FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE;
@ -759,16 +787,6 @@ gst_debug_help (void)
g_print ("%s", gst_debug_category_get_description (cat)); g_print ("%s", gst_debug_category_get_description (cat));
SetConsoleTextAttribute (GetStdHandle (STD_OUTPUT_HANDLE), clear); SetConsoleTextAttribute (GetStdHandle (STD_OUTPUT_HANDLE), clear);
g_print ("\n"); 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 */ #endif /* G_OS_WIN32 */
} else { } else {
g_print ("%-20s %1d %s %s\n", gst_debug_category_get_name (cat), g_print ("%-20s %1d %s %s\n", gst_debug_category_get_name (cat),
@ -815,6 +833,9 @@ parse_one_option (gint opt, const gchar * arg, GError ** err)
case ARG_DEBUG_NO_COLOR: case ARG_DEBUG_NO_COLOR:
gst_debug_set_colored (FALSE); gst_debug_set_colored (FALSE);
break; break;
case ARG_DEBUG_COLOR_MODE:
gst_debug_set_color_mode_from_string (arg);
break;
case ARG_DEBUG_DISABLE: case ARG_DEBUG_DISABLE:
gst_debug_set_active (FALSE); gst_debug_set_active (FALSE);
break; break;
@ -870,6 +891,7 @@ parse_goption_arg (const gchar * opt,
"--gst-debug", ARG_DEBUG}, { "--gst-debug", ARG_DEBUG}, {
"--gst-debug-disable", ARG_DEBUG_DISABLE}, { "--gst-debug-disable", ARG_DEBUG_DISABLE}, {
"--gst-debug-no-color", ARG_DEBUG_NO_COLOR}, { "--gst-debug-no-color", ARG_DEBUG_NO_COLOR}, {
"--gst-debug-color-mode", ARG_DEBUG_COLOR_MODE}, {
"--gst-debug-help", ARG_DEBUG_HELP}, "--gst-debug-help", ARG_DEBUG_HELP},
#endif #endif
{ {

View file

@ -263,7 +263,7 @@ static GSList *__log_functions = NULL;
static gboolean pretty_tags = PRETTY_TAGS_DEFAULT; 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 __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; static FILE *log_file;
@ -900,7 +900,7 @@ gst_debug_construct_win_color (guint colorinfo)
#define CAT_FMT "%20s %s:%d:%s:%s" #define CAT_FMT "%20s %s:%d:%s:%s"
#ifdef G_OS_WIN32 #ifdef G_OS_WIN32
static const guchar levelcolormap[GST_LEVEL_COUNT] = { static const guchar levelcolormap_w32[GST_LEVEL_COUNT] = {
/* GST_LEVEL_NONE */ /* GST_LEVEL_NONE */
FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE, FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE,
/* GST_LEVEL_ERROR */ /* GST_LEVEL_ERROR */
@ -928,7 +928,7 @@ static const guchar available_colors[] = {
FOREGROUND_BLUE, FOREGROUND_RED | FOREGROUND_BLUE, FOREGROUND_BLUE, FOREGROUND_RED | FOREGROUND_BLUE,
FOREGROUND_GREEN | FOREGROUND_BLUE, FOREGROUND_GREEN | FOREGROUND_BLUE,
}; };
#else #endif /* G_OS_WIN32 */
static const gchar *levelcolormap[GST_LEVEL_COUNT] = { static const gchar *levelcolormap[GST_LEVEL_COUNT] = {
"\033[37m", /* GST_LEVEL_NONE */ "\033[37m", /* GST_LEVEL_NONE */
"\033[31;01m", /* GST_LEVEL_ERROR */ "\033[31;01m", /* GST_LEVEL_ERROR */
@ -941,7 +941,6 @@ static const gchar *levelcolormap[GST_LEVEL_COUNT] = {
"\033[37m", /* placeholder for log level 8 */ "\033[37m", /* placeholder for log level 8 */
"\033[37m" /* GST_LEVEL_MEMDUMP */ "\033[37m" /* GST_LEVEL_MEMDUMP */
}; };
#endif
/** /**
* gst_debug_log_default: * gst_debug_log_default:
@ -972,13 +971,13 @@ gst_debug_log_default (GstDebugCategory * category, GstDebugLevel level,
gint pid; gint pid;
GstClockTime elapsed; GstClockTime elapsed;
gchar *obj = NULL; gchar *obj = NULL;
gboolean is_colored; GstDebugColorMode color_mode;
if (level > gst_debug_category_get_threshold (category)) if (level > gst_debug_category_get_threshold (category))
return; return;
pid = getpid (); pid = getpid ();
is_colored = gst_debug_is_colored (); color_mode = gst_debug_get_color_mode ();
if (object) { if (object) {
obj = gst_debug_print_object (object); obj = gst_debug_print_object (object);
@ -989,65 +988,70 @@ gst_debug_log_default (GstDebugCategory * category, GstDebugLevel level,
elapsed = GST_CLOCK_DIFF (_priv_gst_info_start_time, elapsed = GST_CLOCK_DIFF (_priv_gst_info_start_time,
gst_util_get_timestamp ()); gst_util_get_timestamp ());
if (is_colored) { if (color_mode != GST_DEBUG_COLOR_MODE_OFF) {
#ifndef G_OS_WIN32 #ifdef G_OS_WIN32
/* colors, non-windows */ /* We take a lock to keep colors and content together.
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.
* Maybe there is a better way but for now this will do the right * Maybe there is a better way but for now this will do the right
* thing. */ * thing. */
static GMutex win_print_mutex; 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 { \ #define SET_COLOR(c) G_STMT_START { \
if (log_file == stderr) \ if (log_file == stderr) \
SetConsoleTextAttribute (GetStdHandle (STD_ERROR_HANDLE), (c)); \ SetConsoleTextAttribute (GetStdHandle (STD_ERROR_HANDLE), (c)); \
} G_STMT_END } G_STMT_END
g_mutex_lock (&win_print_mutex); /* timestamp */
/* timestamp */ fprintf (log_file, "%" GST_TIME_FORMAT " ", GST_TIME_ARGS (elapsed));
fprintf (log_file, "%" GST_TIME_FORMAT " ", GST_TIME_ARGS (elapsed)); fflush (log_file);
fflush (log_file); /* pid */
/* pid */ SET_COLOR (available_colors[pid % G_N_ELEMENTS (available_colors)]);
SET_COLOR (available_colors[pid % G_N_ELEMENTS (available_colors)]); fprintf (log_file, PID_FMT, pid);
fprintf (log_file, PID_FMT, pid); fflush (log_file);
fflush (log_file); /* thread */
/* thread */ SET_COLOR (clear);
SET_COLOR (clear); fprintf (log_file, " " PTR_FMT " ", g_thread_self ());
fprintf (log_file, " " PTR_FMT " ", g_thread_self ()); fflush (log_file);
fflush (log_file); /* level */
/* level */ SET_COLOR (levelcolormap_w32[level]);
SET_COLOR (levelcolormap[level]); fprintf (log_file, "%s ", gst_debug_level_get_name (level));
fprintf (log_file, "%s ", gst_debug_level_get_name (level)); fflush (log_file);
fflush (log_file); /* category */
/* category */ SET_COLOR (gst_debug_construct_win_color (gst_debug_category_get_color
SET_COLOR (gst_debug_construct_win_color (gst_debug_category_get_color (category)));
(category))); fprintf (log_file, CAT_FMT, gst_debug_category_get_name (category),
fprintf (log_file, CAT_FMT, gst_debug_category_get_name (category), file, line, function, obj);
file, line, function, obj); fflush (log_file);
fflush (log_file); /* message */
/* message */ SET_COLOR (clear);
SET_COLOR (clear); fprintf (log_file, " %s\n", gst_debug_message_get (message));
fprintf (log_file, " %s\n", gst_debug_message_get (message)); fflush (log_file);
fflush (log_file); }
g_mutex_unlock (&win_print_mutex); g_mutex_unlock (&win_print_mutex);
#endif #endif
} else { } else {
@ -1248,13 +1252,51 @@ gst_debug_remove_log_function_by_data (gpointer data)
* @colored: Whether to use colored output or not * @colored: Whether to use colored output or not
* *
* Sets or unsets the use of coloured debugging output. * 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(). * This function may be called before gst_init().
*/ */
void void
gst_debug_set_colored (gboolean colored) 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);
} }
/** /**
@ -1267,7 +1309,21 @@ gst_debug_set_colored (gboolean colored)
gboolean gboolean
gst_debug_is_colored (void) 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);
} }
/** /**
@ -1938,12 +1994,28 @@ 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 gboolean
gst_debug_is_colored (void) gst_debug_is_colored (void)
{ {
return FALSE; return FALSE;
} }
GstDebugColorMode
gst_debug_get_color_mode (void)
{
return GST_DEBUG_COLOR_MODE_OFF;
}
void void
gst_debug_set_threshold_from_string (const gchar * list, gboolean reset) gst_debug_set_threshold_from_string (const gchar * list, gboolean reset)
{ {

View file

@ -159,6 +159,20 @@ typedef enum {
GST_DEBUG_UNDERLINE = 0x0200 GST_DEBUG_UNDERLINE = 0x0200
} GstDebugColorFlags; } 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_FG_MASK (0x000F)
#define GST_DEBUG_BG_MASK (0x00F0) #define GST_DEBUG_BG_MASK (0x00F0)
#define GST_DEBUG_FORMAT_MASK (0xFF00) #define GST_DEBUG_FORMAT_MASK (0xFF00)
@ -339,7 +353,10 @@ void gst_debug_set_active (gboolean active);
gboolean gst_debug_is_active (void); gboolean gst_debug_is_active (void);
void gst_debug_set_colored (gboolean colored); 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); gboolean gst_debug_is_colored (void);
GstDebugColorMode gst_debug_get_color_mode (void);
void gst_debug_set_default_threshold (GstDebugLevel level); void gst_debug_set_default_threshold (GstDebugLevel level);
GstDebugLevel gst_debug_get_default_threshold (void); GstDebugLevel gst_debug_get_default_threshold (void);
@ -1239,7 +1256,10 @@ GST_TRACE (const char *format, ...)
#define gst_debug_set_active(active) G_STMT_START{ }G_STMT_END #define gst_debug_set_active(active) G_STMT_START{ }G_STMT_END
#define gst_debug_is_active() (FALSE) #define gst_debug_is_active() (FALSE)
#define gst_debug_set_colored(colored) G_STMT_START{ }G_STMT_END #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_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_set_default_threshold(level) G_STMT_START{ }G_STMT_END
#define gst_debug_get_default_threshold() (GST_LEVEL_NONE) #define gst_debug_get_default_threshold() (GST_LEVEL_NONE)
#define gst_debug_set_threshold_for_name(name,level) G_STMT_START{ }G_STMT_END #define gst_debug_set_threshold_for_name(name,level) G_STMT_START{ }G_STMT_END

View file

@ -101,6 +101,16 @@ ANSI escape sequences. Using this option causes \fIGStreamer\fP
to print messages without color. Setting the \fBGST_DEBUG_NO_COLOR\fR to print messages without color. Setting the \fBGST_DEBUG_NO_COLOR\fR
environment variable will achieve the same thing. environment variable will achieve the same thing.
.TP 8 .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 .B \-\-gst\-debug\-disable
Disables debugging. Disables debugging.
.TP 8 .TP 8

View file

@ -2,7 +2,7 @@
# #
# based on plot-timeline.py by Federico Mena-Quintero <federico at ximian dotcom> # based on plot-timeline.py by Federico Mena-Quintero <federico at ximian dotcom>
# example: # 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 # gst-plot-timeline.py debug.log --output=debug.png
import math import math
@ -271,7 +271,7 @@ def main(args):
return 1 return 1
if len(args) != 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 return 1
in_filename = args[0] in_filename = args[0]

View file

@ -376,6 +376,9 @@ EXPORTS
gst_debug_remove_log_function_by_data gst_debug_remove_log_function_by_data
gst_debug_set_active gst_debug_set_active
gst_debug_set_colored 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_default_threshold
gst_debug_set_threshold_for_name gst_debug_set_threshold_for_name
gst_debug_set_threshold_from_string gst_debug_set_threshold_from_string