By default colors are disabled. Use WINEDEBUG_COLOR=1 to enable colors in debug messages.
Signed-off-by: Rafał Harabień rafalh1992@o2.pl --- libs/wine/debug.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-)
diff --git a/libs/wine/debug.c b/libs/wine/debug.c index 8b04ef9..af84e67 100644 --- a/libs/wine/debug.c +++ b/libs/wine/debug.c @@ -39,12 +39,14 @@ WINE_DECLARE_DEBUG_CHANNEL(pid); #endif
static const char * const debug_classes[] = { "fixme", "err", "warn", "trace" }; +static const char * const debug_classes_color[] = { "\e[93m", "\e[91m", "\e[93m", "" };
#define MAX_DEBUG_OPTIONS 256
static unsigned char default_flags = (1 << __WINE_DBCL_ERR) | (1 << __WINE_DBCL_FIXME); static int nb_debug_options = -1; static struct __wine_debug_channel debug_options[MAX_DEBUG_OPTIONS]; +static int debug_color = 0;
static struct __wine_debug_functions funcs;
@@ -193,7 +195,7 @@ static void debug_usage(void) /* initialize all options at startup */ static void debug_init(void) { - char *wine_debug; + char *wine_debug, *color; struct stat st1, st2;
if (nb_debug_options != -1) return; /* already initialized */ @@ -212,6 +214,8 @@ static void debug_init(void) if (!strcmp( wine_debug, "help" )) debug_usage(); parse_options( wine_debug ); } + color = getenv("WINEDEBUG_COLOR"); + if (color != NULL) debug_color = atoi(color); }
/* varargs wrapper for funcs.dbg_vprintf */ @@ -406,6 +410,7 @@ static int default_dbg_vlog( enum __wine_debug_class cls, struct __wine_debug_ch const char *func, const char *format, va_list args ) { int ret = 0; + const char *color_reset = "\e[39m";
#if defined(__MINGW32__) || defined(_MSC_VER) if (TRACE_ON(pid)) @@ -414,9 +419,16 @@ static int default_dbg_vlog( enum __wine_debug_class cls, struct __wine_debug_ch ret += wine_dbg_printf( "%04x:", GetCurrentThreadId() ); #endif if (cls < sizeof(debug_classes)/sizeof(debug_classes[0])) + { + if (debug_color) + ret += wine_dbg_printf( "%s", debug_classes_color[cls] ); ret += wine_dbg_printf( "%s:%s:%s ", debug_classes[cls], channel->name, func ); + } if (format) ret += funcs.dbg_vprintf( format, args ); + if (debug_color) + ret += wine_dbg_printf( "%s", color_reset ); + return ret; }