Added padding support and set_pattern to custom_flags

This commit is contained in:
Gabi Melman
2020-03-21 15:03:41 +02:00
parent d1a1024465
commit 60a8c5f1c9
4 changed files with 70 additions and 28 deletions

View File

@@ -1024,8 +1024,9 @@ SPDLOG_INLINE void pattern_formatter::format(const details::log_msg &msg, memory
details::fmt_helper::append_string_view(eol_, dest);
}
SPDLOG_INLINE void pattern_formatter::recompile()
SPDLOG_INLINE void pattern_formatter::set_pattern(std::string pattern)
{
pattern_ = std::move(pattern);
compile_pattern_(pattern_);
}
@@ -1041,15 +1042,19 @@ SPDLOG_INLINE std::tm pattern_formatter::get_time_(const details::log_msg &msg)
template<typename Padder>
SPDLOG_INLINE void pattern_formatter::handle_flag_(char flag, details::padding_info padding)
{
// process custom flags
auto it = custom_handlers_.find(flag);
if (it != custom_handlers_.end())
if (it != custom_handlers_.end())
{
formatters_.push_back(it->second->clone());
auto custom_handler = it->second->clone();
custom_handler->set_padding_info(padding);
formatters_.push_back(std::move(custom_handler));
return;
}
switch (flag)
{
// process built-in flags
switch (flag)
{
case ('+'): // default formatter
formatters_.push_back(details::make_unique<details::full_formatter>(padding));
break;