1
0
Fork 0
mirror of https://git.rwth-aachen.de/acs/public/villas/node/ synced 2025-03-09 00:00:00 +01:00

spdlog: patch name formatter to implement fixed width names in format

This commit is contained in:
daniel-k 2018-01-10 15:41:27 +01:00
parent b33b4d27d9
commit f2a5e7af22

View file

@ -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
}
};
}