From 96382d5621012f1b886c2d15d92198c42d505abd Mon Sep 17 00:00:00 2001 From: levlam Date: Wed, 10 Nov 2021 19:06:12 +0300 Subject: [PATCH] Output no_color only if there was a color. --- tdutils/td/utils/logging.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tdutils/td/utils/logging.cpp b/tdutils/td/utils/logging.cpp index ebb528df8..85d14dcd5 100644 --- a/tdutils/td/utils/logging.cpp +++ b/tdutils/td/utils/logging.cpp @@ -208,6 +208,7 @@ class DefaultLog final : public LogInterface { } #elif !TD_WINDOWS Slice color; + Slice no_color("\x1b[0m"); switch (log_level) { case VERBOSITY_NAME(FATAL): case VERBOSITY_NAME(ERROR): @@ -220,10 +221,9 @@ class DefaultLog final : public LogInterface { color = Slice("\x1b[1;36m"); // cyan break; default: - // no color + no_color = Slice(); break; } - Slice no_color("\x1b[0m"); if (!slice.empty() && slice.back() == '\n') { TsCerr() << color << slice.substr(0, slice.size() - 1) << no_color << "\n"; } else {