28 JsonFormatter() : message_formatter_(
"%v", spdlog::pattern_time_type::local, std::string{}) {}
30 void format(
const spdlog::details::log_msg& msg, spdlog::memory_buf_t& dest)
override {
31 spdlog::memory_buf_t message_buf;
32 message_formatter_.format(msg, message_buf);
34 detail::make_log_event(msg, std::string_view(message_buf.data(), message_buf.size()));
36 const nlohmann::json j = event;
37 const std::string out = j.dump();
38 spdlog::details::fmt_helper::append_string_view(out, dest);
42 [[nodiscard]] std::unique_ptr<spdlog::formatter> clone()
const override {
43 return std::make_unique<JsonFormatter>();
47 spdlog::pattern_formatter message_formatter_;