From f4f7b0c426a7169a0f9865f5410682d408e5dfd0 Mon Sep 17 00:00:00 2001 From: Martin Pulec Date: Thu, 15 Sep 2022 10:08:48 +0200 Subject: [PATCH] Logger: switch order of TERM_RESET and '\n' If logged message ends with '\n', put TERM_RESET before it (it prevents keeping the color if someone writes to stderr directly). --- src/debug.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/debug.h b/src/debug.h index 1c881dbe4..363b7d9c6 100644 --- a/src/debug.h +++ b/src/debug.h @@ -278,6 +278,9 @@ public: } std::string msg = oss.str(); + if (msg.at(msg.size() - sizeof TERM_RESET) == '\n') { // switch TERM_RESET and '\n' + msg.replace(msg.size() - sizeof TERM_RESET, sizeof TERM_RESET + 1, TERM_RESET "\n"); + } if (!get_log_output().is_interactive()) { msg = prune_ansi_sequences_str(msg.c_str());