From 4660254072e5a68c3cd73c77bae03435171e8808 Mon Sep 17 00:00:00 2001 From: "Roger A. Light" Date: Tue, 28 May 2019 22:00:11 +0100 Subject: [PATCH] Colour internal logs for visibility. --- src/logging.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/logging.c b/src/logging.c index d956643d..bcb6a156 100644 --- a/src/logging.c +++ b/src/logging.c @@ -373,10 +373,19 @@ int log__printf(struct mosquitto *mosq, int priority, const char *fmt, ...) void log__internal(const char *fmt, ...) { va_list va; + char buf[200]; + int len; va_start(va, fmt); - log__vprintf(MOSQ_LOG_INTERNAL, fmt, va); + len = vsnprintf(buf, 200, fmt, va); va_end(va); + + if(len >= 200){ + log__printf(NULL, MOSQ_LOG_INTERNAL, "Internal log buffer too short (%d)", len); + return; + } + + log__printf(NULL, MOSQ_LOG_INTERNAL, "%s%s%s", "\e[32m", buf, "\e[0m"); } int mosquitto_log_vprintf(int level, const char *fmt, va_list va)