|
|
@ -929,6 +929,54 @@ private:
|
|
|
|
log_clock::time_point last_message_time_;
|
|
|
|
log_clock::time_point last_message_time_;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// attribute formatting: stub
|
|
|
|
|
|
|
|
class attr_formatter_start final : public flag_formatter
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
|
|
|
explicit attr_formatter_start(padding_info padinfo)
|
|
|
|
|
|
|
|
: flag_formatter(padinfo, details::attr_flags::start)
|
|
|
|
|
|
|
|
{}
|
|
|
|
|
|
|
|
void format(const details::log_msg &, const std::tm &, memory_buf_t &dest) override
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
fmt_helper::append_string_view("", dest);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
class attr_formatter_stop final : public flag_formatter
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
|
|
|
explicit attr_formatter_stop(padding_info padinfo)
|
|
|
|
|
|
|
|
: flag_formatter(padinfo, details::attr_flags::stop)
|
|
|
|
|
|
|
|
{}
|
|
|
|
|
|
|
|
void format(const details::log_msg &, const std::tm &, memory_buf_t &dest) override
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
fmt_helper::append_string_view("", dest);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class attr_formatter_key final : public flag_formatter
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
|
|
|
explicit attr_formatter_key(padding_info padinfo)
|
|
|
|
|
|
|
|
: flag_formatter(padinfo, details::attr_flags::key)
|
|
|
|
|
|
|
|
{}
|
|
|
|
|
|
|
|
void format(const details::log_msg &, const std::tm &, memory_buf_t &dest) override
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
fmt_helper::append_string_view("", dest);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class attr_formatter_value final : public flag_formatter
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
|
|
|
explicit attr_formatter_value(padding_info padinfo)
|
|
|
|
|
|
|
|
: flag_formatter(padinfo, details::attr_flags::value)
|
|
|
|
|
|
|
|
{}
|
|
|
|
|
|
|
|
void format(const details::log_msg &, const std::tm &, memory_buf_t &dest) override
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
fmt_helper::append_string_view("", dest);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
// Full info formatter
|
|
|
|
// Full info formatter
|
|
|
|
// pattern: [%Y-%m-%d %H:%M:%S.%e] [%n] [%l] [%s:%#] %v
|
|
|
|
// pattern: [%Y-%m-%d %H:%M:%S.%e] [%n] [%l] [%s:%#] %v
|
|
|
|
class full_formatter final : public flag_formatter
|
|
|
|
class full_formatter final : public flag_formatter
|
|
|
@ -1012,7 +1060,14 @@ public:
|
|
|
|
fmt_helper::append_string_view(msg.payload, dest);
|
|
|
|
fmt_helper::append_string_view(msg.payload, dest);
|
|
|
|
|
|
|
|
|
|
|
|
if (msg.attributes.size() > 0) {
|
|
|
|
if (msg.attributes.size() > 0) {
|
|
|
|
|
|
|
|
// by default uses logfmt-esque kv pairs
|
|
|
|
fmt_helper::append_string_view(" | ", dest); // separate message from attributes
|
|
|
|
fmt_helper::append_string_view(" | ", dest); // separate message from attributes
|
|
|
|
|
|
|
|
for (const details::attr& a : msg.attributes) {
|
|
|
|
|
|
|
|
details::fmt_helper::append_string_view(a.key, dest);
|
|
|
|
|
|
|
|
details::fmt_helper::append_string_view("=\"", dest);
|
|
|
|
|
|
|
|
details::fmt_helper::append_string_view(a.value, dest);
|
|
|
|
|
|
|
|
details::fmt_helper::append_string_view("\" ", dest);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -1076,16 +1131,33 @@ SPDLOG_INLINE void pattern_formatter::format(const details::log_msg &msg, memory
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
for (auto &f : formatters_)
|
|
|
|
auto it_end = formatters_.begin();
|
|
|
|
|
|
|
|
for (auto it = formatters_.begin(); it != formatters_.end(); ++it)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
f->format(msg, cached_tm_, dest);
|
|
|
|
if ((*it)->flag_ == details::attr_flags::start) {
|
|
|
|
}
|
|
|
|
if (msg.attributes.size() == 0) {
|
|
|
|
// TODO: make separate function, and add a custom format to attributes (for now just using logfmt)
|
|
|
|
while((*it)->flag_ != details::attr_flags::stop && it != formatters_.end()) ++it;
|
|
|
|
for (const details::attr& a : msg.attributes) {
|
|
|
|
it_end = it;
|
|
|
|
details::fmt_helper::append_string_view(a.key, dest);
|
|
|
|
}
|
|
|
|
details::fmt_helper::append_string_view("=\"", dest);
|
|
|
|
for (const details::attr& a : msg.attributes) {
|
|
|
|
details::fmt_helper::append_string_view(a.value, dest);
|
|
|
|
for (auto it2 = it; it2 != formatters_.end(); ++it2) {
|
|
|
|
details::fmt_helper::append_string_view("\" ", dest);
|
|
|
|
if ((*it2)->flag_ == details::attr_flags::stop) {
|
|
|
|
|
|
|
|
it_end = it2;
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
} else if ((*it2)->flag_ == details::attr_flags::key) {
|
|
|
|
|
|
|
|
// custom formatting function overload makes this even more messy with reinterpret casts,
|
|
|
|
|
|
|
|
// will just do manual key addition
|
|
|
|
|
|
|
|
details::fmt_helper::append_string_view(a.key, dest);
|
|
|
|
|
|
|
|
} else if ((*it2)->flag_ == details::attr_flags::value) {
|
|
|
|
|
|
|
|
details::fmt_helper::append_string_view(a.value, dest);
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
(*it2)->format(msg, cached_tm_, dest);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
it = it_end;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
(*it)->format(msg, cached_tm_, dest);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// write eol
|
|
|
|
// write eol
|
|
|
@ -1320,6 +1392,22 @@ SPDLOG_INLINE void pattern_formatter::handle_flag_(char flag, details::padding_i
|
|
|
|
formatters_.push_back(details::make_unique<details::elapsed_formatter<Padder, std::chrono::seconds>>(padding));
|
|
|
|
formatters_.push_back(details::make_unique<details::elapsed_formatter<Padder, std::chrono::seconds>>(padding));
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
case ('('): // start attribute formatting
|
|
|
|
|
|
|
|
formatters_.push_back(details::make_unique<details::attr_formatter_start>(padding));
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
case ('K'): // attribute key
|
|
|
|
|
|
|
|
formatters_.push_back(details::make_unique<details::attr_formatter_key>(padding));
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
case ('V'): // attribute value
|
|
|
|
|
|
|
|
formatters_.push_back(details::make_unique<details::attr_formatter_value>(padding));
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
case (')'): // stop attribute formatting
|
|
|
|
|
|
|
|
formatters_.push_back(details::make_unique<details::attr_formatter_stop>(padding));
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
|
|
default: // Unknown flag appears as is
|
|
|
|
default: // Unknown flag appears as is
|
|
|
|
auto unknown_flag = details::make_unique<details::aggregate_formatter>();
|
|
|
|
auto unknown_flag = details::make_unique<details::aggregate_formatter>();
|
|
|
|
|
|
|
|
|
|
|
|