keep old range-based for loop for non-attribute code

pull/2687/head
Bailey Chittle 3 years ago
parent 443d016e89
commit f34970334b

@ -1131,14 +1131,25 @@ SPDLOG_INLINE void pattern_formatter::format(const details::log_msg &msg, memory
}
}
if (msg.attributes.size() == 0) {
// non-iterator, a bit cleaner, still need to ignore new formatting flags
bool ignore_formatter = false;
for (auto& f : formatters_) {
if (f->flag_ == details::attr_flags::start) {
ignore_formatter = true;
} else if (f->flag_ == details::attr_flags::stop) {
ignore_formatter = false;
}
if (!ignore_formatter)
f->format(msg, cached_tm_, dest);
}
} else {
// ugly formatter iterator, due to needing to go back to previous iterators to repeat kv pairs
auto it_end = formatters_.begin();
for (auto it = formatters_.begin(); it != formatters_.end(); ++it)
{
if ((*it)->flag_ == details::attr_flags::start) {
if (msg.attributes.size() == 0) {
while((*it)->flag_ != details::attr_flags::stop && it != formatters_.end()) ++it;
it_end = it;
}
for (const details::attr& a : msg.attributes) {
for (auto it2 = it; it2 != formatters_.end(); ++it2) {
if ((*it2)->flag_ == details::attr_flags::stop) {
@ -1159,6 +1170,7 @@ SPDLOG_INLINE void pattern_formatter::format(const details::log_msg &msg, memory
}
(*it)->format(msg, cached_tm_, dest);
}
}
// write eol
details::fmt_helper::append_string_view(eol_, dest);

Loading…
Cancel
Save