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).
This commit is contained in:
Martin Pulec
2022-09-15 10:08:48 +02:00
parent 1ae4457729
commit f4f7b0c426

View File

@@ -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());