diff --git a/include/spdlog/details/pattern_formatter_impl.h b/include/spdlog/details/pattern_formatter_impl.h index d8b92f9b..a7259e96 100644 --- a/include/spdlog/details/pattern_formatter_impl.h +++ b/include/spdlog/details/pattern_formatter_impl.h @@ -421,15 +421,15 @@ private: std::string _str; }; -// set the color range. expect it to be in the form of "%^colored text%$" -class start_color_formatter SPDLOG_FINAL : public flag_formatter +// mark the color range. expect it to be in the form of "%^colored text%$" +class color_start_formatter SPDLOG_FINAL : public flag_formatter { void format(details::log_msg &msg, const std::tm &) override { msg.color_range_start = msg.formatted.size(); } }; -class stop_color_formatter SPDLOG_FINAL : public flag_formatter +class color_stop_formatter SPDLOG_FINAL : public flag_formatter { void format(details::log_msg &msg, const std::tm &) override { @@ -438,7 +438,6 @@ class stop_color_formatter SPDLOG_FINAL : public flag_formatter }; // Full info formatter - // pattern: [%Y-%m-%d %H:%M:%S.%e] [%n] [%l] %v class full_formatter SPDLOG_FINAL : public flag_formatter { @@ -667,11 +666,13 @@ inline void spdlog::pattern_formatter::handle_flag(char flag) case ('i'): _formatters.emplace_back(new details::i_formatter()); break; + case ('^'): - _formatters.emplace_back(new details::start_color_formatter()); + _formatters.emplace_back(new details::color_start_formatter()); break; + case ('$'): - _formatters.emplace_back(new details::stop_color_formatter()); + _formatters.emplace_back(new details::color_stop_formatter()); break; default: // Unknown flag appears as is