From 14950926ed7f01f5808a6d960b3ebb09c5268a80 Mon Sep 17 00:00:00 2001 From: Muhammed Galib Uludag Date: Sun, 27 Jun 2021 22:50:31 +0300 Subject: [PATCH] ignore pattern formatting for message section in mongodb --- include/spdlog/sinks/mongo_sink.h | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/include/spdlog/sinks/mongo_sink.h b/include/spdlog/sinks/mongo_sink.h index ccb02e70..f924f4fb 100644 --- a/include/spdlog/sinks/mongo_sink.h +++ b/include/spdlog/sinks/mongo_sink.h @@ -12,7 +12,6 @@ #include "spdlog/common.h" #include "spdlog/details/log_msg.h" -#include "spdlog/pattern_formatter.h" #include "spdlog/sinks/base_sink.h" #include @@ -34,7 +33,6 @@ public: client_ = std::make_unique(mongocxx::uri{uri}); db_name_ = db_name; coll_name_ = collection_name; - set_pattern("%v"); } catch (const std::exception) { throw spdlog_ex("Error opening database"); } @@ -48,12 +46,10 @@ protected: using bsoncxx::builder::stream::finalize; if (client_ != nullptr) { - memory_buf_t formatted; - base_sink::formatter_->format(msg, formatted); auto doc = document{} << "timestamp" << bsoncxx::types::b_date(msg.time) << "level" << level::to_string_view(msg.level).data() << "message" - << std::string(formatted.begin(), formatted.end()) + << std::string(msg.payload.begin(), msg.payload.end()) << "logger_name" << std::string(msg.logger_name.begin(), msg.logger_name.end()) << "thread_id" << static_cast(msg.thread_id) << finalize;