mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-02-22 22:16:22 +00:00
info: flush again after every line of debug output
g_printerr() used to do this for us. Also use libc's fprintf() functions, to make sure the stderr pointer we use is actually compatible with the libc linked against by GStreamer (which apparently may not always be the same as what GLib is linked against on windows), and we don't need the functionality ensured by g_fprintf(). Fixes #625295.
This commit is contained in:
parent
1f4ab2065c
commit
4cecd73c93
1 changed files with 20 additions and 10 deletions
|
@ -938,11 +938,12 @@ gst_debug_log_default (GstDebugCategory * category, GstDebugLevel level,
|
|||
levelcolor = levelcolormap[level];
|
||||
|
||||
#define PRINT_FMT " %s"PID_FMT"%s "PTR_FMT" %s%s%s %s"CAT_FMT"%s %s\n"
|
||||
g_fprintf (log_file, "%" GST_TIME_FORMAT PRINT_FMT, GST_TIME_ARGS (elapsed),
|
||||
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
|
||||
|
@ -951,37 +952,46 @@ gst_debug_log_default (GstDebugCategory * category, GstDebugLevel level,
|
|||
* thing. */
|
||||
static GStaticMutex win_print_mutex = G_STATIC_MUTEX_INIT;
|
||||
const gint clear = FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE;
|
||||
#define SET_COLOR(c) \
|
||||
SetConsoleTextAttribute (GetStdHandle (STD_ERROR_HANDLE), (c));
|
||||
#define SET_COLOR(c) G_STMT_START { \
|
||||
if (log_file == stderr) { \
|
||||
SetConsoleTextAttribute (GetStdHandle (STD_ERROR_HANDLE), (c)); \
|
||||
} G_STMT_END
|
||||
g_static_mutex_lock (&win_print_mutex);
|
||||
/* timestamp */
|
||||
g_fprintf (log_file, "%" GST_TIME_FORMAT " ", GST_TIME_ARGS (elapsed));
|
||||
fprintf (log_file, "%" GST_TIME_FORMAT " ", GST_TIME_ARGS (elapsed));
|
||||
fflush (log_file);
|
||||
/* pid */
|
||||
SET_COLOR (available_colors[pid % G_N_ELEMENTS (available_colors)]);
|
||||
g_fprintf (log_file, PID_FMT, pid);
|
||||
fprintf (log_file, PID_FMT, pid);
|
||||
fflush (log_file);
|
||||
/* thread */
|
||||
SET_COLOR (clear);
|
||||
g_fprintf (log_file, " " PTR_FMT " ", g_thread_self ());
|
||||
fprintf (log_file, " " PTR_FMT " ", g_thread_self ());
|
||||
fflush (log_file);
|
||||
/* level */
|
||||
SET_COLOR (levelcolormap[level]);
|
||||
g_fprintf (log_file, "%s ", gst_debug_level_get_name (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)));
|
||||
g_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);
|
||||
fflush (log_file);
|
||||
/* message */
|
||||
SET_COLOR (clear);
|
||||
g_fprintf (log_file, " %s\n", gst_debug_message_get (message));
|
||||
fprintf (log_file, " %s\n", gst_debug_message_get (message));
|
||||
fflush (log_file);
|
||||
g_static_mutex_unlock (&win_print_mutex);
|
||||
#endif
|
||||
} else {
|
||||
/* no color, all platforms */
|
||||
#define PRINT_FMT " "PID_FMT" "PTR_FMT" %s "CAT_FMT" %s\n"
|
||||
g_fprintf (log_file, "%" GST_TIME_FORMAT PRINT_FMT, GST_TIME_ARGS (elapsed),
|
||||
fprintf (log_file, "%" GST_TIME_FORMAT PRINT_FMT, GST_TIME_ARGS (elapsed),
|
||||
pid, g_thread_self (), gst_debug_level_get_name (level),
|
||||
gst_debug_category_get_name (category), file, line, function, obj,
|
||||
gst_debug_message_get (message));
|
||||
fflush (log_file);
|
||||
#undef PRINT_FMT
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue