From 4de6390d25baa04e7cc2bb75936b796576473d40 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kacper=20Michaj=C5=82ow?= Date: Fri, 13 Sep 2024 21:06:42 +0200 Subject: [PATCH] msg: don't use bold colors and instead use bright ones Also avoid regular white/black, because it is often the terminal background and invisible as foreground color. Change debug messages to blue while at it to differentiate them from trace ones. --- common/msg.c | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/common/msg.c b/common/msg.c index 2a1f151e0f..792d233892 100644 --- a/common/msg.c +++ b/common/msg.c @@ -321,13 +321,27 @@ static void set_term_color(void *talloc_ctx, bstr *text, int c) bstr_xappend(talloc_ctx, text, bstr0("\033[0m")); return; } - - bstr_xappend_asprintf(talloc_ctx, text, "\033[%d;3%dm", c >> 3, c & 7); + // Pure black to gray + if (c == 0) + c += 8; + // Pure white to light one + if (c == 15) + c -= 8; + bstr_xappend_asprintf(talloc_ctx, text, "\033[%d%dm", c >= 8 ? 9 : 3, c & 7); } static void set_msg_color(void *talloc_ctx, bstr *text, int lev) { - static const int v_colors[] = {9, 1, 3, -1, -1, 2, 8, 8, 8, -1}; + static const int v_colors[] = { + [MSGL_FATAL] = 9, // bright red + [MSGL_ERR] = 1, // red + [MSGL_WARN] = 3, // yellow + [MSGL_INFO] = -1, // default + [MSGL_STATUS] = -1, // default + [MSGL_V] = 2, // green + [MSGL_DEBUG] = 4, // blue + [MSGL_TRACE] = 8, // bright black aka. gray + }; set_term_color(talloc_ctx, text, v_colors[lev]); }