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:
parent
b33b4d27d9
commit
f2a5e7af22
1 changed files with 12 additions and 0 deletions
|
@ -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
|
||||
}
|
||||
};
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue