From af123edb57d1f268a2520025aad715207ec4e828 Mon Sep 17 00:00:00 2001 From: Alberto Leiva Popper Date: Tue, 21 Oct 2025 17:54:20 -0600 Subject: [PATCH] Upgrade the color of trace errors and trace warnings Validation errors and warnings need to be logged on TRC level, because the immediate admin doesn't care about them. However, I still want to be able to spot them easily, so color them red and yellow, respectively. --- src/log.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/log.c b/src/log.c index c5e9d14d..63c3ea6f 100644 --- a/src/log.c +++ b/src/log.c @@ -36,6 +36,11 @@ static struct level ERR = { LOG_ERR, "ERR", "error", CLR_ERR, CLR_RST }; static struct level CRT = { LOG_CRIT, "CRT", "critical", CLR_CRT, CLR_RST }; static struct level PNC = { LOG_EMERG, "PNC", "panic", CLR_PNC, CLR_RST }; +/* Validation warning (reported, so logged on trace level, except yellow) */ +static struct level TRC_WRN = { LOG_DEBUG, "TRW", NULL, CLR_WRN, CLR_RST }; +/* Validation error (reported, so logged on trace level, except red) */ +static struct level TRC_ERR = { LOG_DEBUG, "TRE", NULL, CLR_ERR, CLR_RST }; + struct logger { void (*cb)(struct logger *, struct level *, char const *, va_list); @@ -324,7 +329,7 @@ pr_wrn(const char *fmt, ...) va_start(args, fmt); report(lvl->tag, fmt, args); va_end(args); - lvl = &TRC; + lvl = &TRC_WRN; } SLIST_FOREACH(lgr, &listeners, lh) { @@ -349,7 +354,7 @@ pr_err(const char *fmt, ...) va_start(args, fmt); report(lvl->tag, fmt, args); va_end(args); - lvl = &TRC; + lvl = &TRC_ERR; } SLIST_FOREACH(lgr, &listeners, lh) { @@ -394,7 +399,7 @@ pr_crypto_err(const char *fmt, ...) va_start(args, fmt); report(lvl->tag, fmt, args); va_end(args); - lvl = &TRC; + lvl = &TRC_ERR; } SLIST_FOREACH(lgr, &listeners, lh) { -- 2.47.3