From f2a5e7af22e6949f652036ec56ce0ee6b9cb79ed Mon Sep 17 00:00:00 2001 From: daniel-k Date: Wed, 10 Jan 2018 15:41:27 +0100 Subject: [PATCH] spdlog: patch name formatter to implement fixed width names in format --- .../include/spdlog/details/pattern_formatter_impl.h | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/fpga/thirdparty/spdlog/include/spdlog/details/pattern_formatter_impl.h b/fpga/thirdparty/spdlog/include/spdlog/details/pattern_formatter_impl.h index a73f5deab..de0f0f2d5 100644 --- a/fpga/thirdparty/spdlog/include/spdlog/details/pattern_formatter_impl.h +++ b/fpga/thirdparty/spdlog/include/spdlog/details/pattern_formatter_impl.h @@ -39,9 +39,21 @@ namespace { class name_formatter:public flag_formatter { + std::string center(std::string input, int width) { + const auto whitespace = width - input.length(); + return std::string(whitespace / 2, ' ') + + input + + std::string(whitespace / 2, ' ') + + ((whitespace % 2 == 0) ? "" : " "); + } + void format(details::log_msg& msg, const std::tm&) override { +#ifdef SPDLOG_NAME_WIDTH + msg.formatted << center(*msg.logger_name, SPDLOG_NAME_WIDTH); +#else msg.formatted << *msg.logger_name; +#endif } }; }