|
|
|
@ -10,7 +10,11 @@
|
|
|
|
|
#include <spdlog/details/fmt_helper.h>
|
|
|
|
|
#include <spdlog/details/log_msg.h>
|
|
|
|
|
#include <spdlog/details/os.h>
|
|
|
|
|
|
|
|
|
|
#ifndef SPDLOG_NO_TLS
|
|
|
|
|
#include <spdlog/mdc.h>
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
#include <spdlog/fmt/fmt.h>
|
|
|
|
|
#include <spdlog/formatter.h>
|
|
|
|
|
|
|
|
|
@ -786,6 +790,7 @@ private:
|
|
|
|
|
|
|
|
|
|
// Class for formatting Mapped Diagnostic Context (MDC) in log messages.
|
|
|
|
|
// Example: [logger-name] [info] [mdc_key_1:mdc_value_1 mdc_key_2:mdc_value_2] some message
|
|
|
|
|
#ifndef SPDLOG_NO_TLS
|
|
|
|
|
template <typename ScopedPadder>
|
|
|
|
|
class mdc_formatter : public flag_formatter {
|
|
|
|
|
public:
|
|
|
|
@ -824,6 +829,7 @@ public:
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
// Full info formatter
|
|
|
|
|
// pattern: [%Y-%m-%d %H:%M:%S.%e] [%n] [%l] [%s:%#] %v
|
|
|
|
@ -901,6 +907,7 @@ public:
|
|
|
|
|
dest.push_back(' ');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#ifndef SPDLOG_NO_TLS
|
|
|
|
|
// add mdc if present
|
|
|
|
|
auto &mdc_map = mdc::get_context();
|
|
|
|
|
if (!mdc_map.empty()) {
|
|
|
|
@ -909,6 +916,7 @@ public:
|
|
|
|
|
dest.push_back(']');
|
|
|
|
|
dest.push_back(' ');
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
// fmt_helper::append_string_view(msg.msg(), dest);
|
|
|
|
|
fmt_helper::append_string_view(msg.payload, dest);
|
|
|
|
|
}
|
|
|
|
@ -916,7 +924,11 @@ public:
|
|
|
|
|
private:
|
|
|
|
|
std::chrono::seconds cache_timestamp_{0};
|
|
|
|
|
memory_buf_t cached_datetime_;
|
|
|
|
|
|
|
|
|
|
#ifndef SPDLOG_NO_TLS
|
|
|
|
|
mdc_formatter<null_scoped_padder> mdc_formatter_{padding_info{}};
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
} // namespace details
|
|
|
|
@ -1211,9 +1223,11 @@ SPDLOG_INLINE void pattern_formatter::handle_flag_(char flag, details::padding_i
|
|
|
|
|
padding));
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
#ifndef SPDLOG_NO_TLS // mdc formatter requires TLS support
|
|
|
|
|
case ('&'):
|
|
|
|
|
formatters_.push_back(details::make_unique<details::mdc_formatter<Padder>>(padding));
|
|
|
|
|
break;
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
default: // Unknown flag appears as is
|
|
|
|
|
auto unknown_flag = details::make_unique<details::aggregate_formatter>();
|
|
|
|
|