mirror of
https://github.com/gabime/spdlog.git
synced 2025-01-13 09:20:25 +08:00
ignore pattern formatting for message section in mongodb
This commit is contained in:
parent
baa3b1a07e
commit
14950926ed
@ -12,7 +12,6 @@
|
|||||||
|
|
||||||
#include "spdlog/common.h"
|
#include "spdlog/common.h"
|
||||||
#include "spdlog/details/log_msg.h"
|
#include "spdlog/details/log_msg.h"
|
||||||
#include "spdlog/pattern_formatter.h"
|
|
||||||
#include "spdlog/sinks/base_sink.h"
|
#include "spdlog/sinks/base_sink.h"
|
||||||
#include <spdlog/details/synchronous_factory.h>
|
#include <spdlog/details/synchronous_factory.h>
|
||||||
|
|
||||||
@ -34,7 +33,6 @@ public:
|
|||||||
client_ = std::make_unique<mongocxx::client>(mongocxx::uri{uri});
|
client_ = std::make_unique<mongocxx::client>(mongocxx::uri{uri});
|
||||||
db_name_ = db_name;
|
db_name_ = db_name;
|
||||||
coll_name_ = collection_name;
|
coll_name_ = collection_name;
|
||||||
set_pattern("%v");
|
|
||||||
} catch (const std::exception) {
|
} catch (const std::exception) {
|
||||||
throw spdlog_ex("Error opening database");
|
throw spdlog_ex("Error opening database");
|
||||||
}
|
}
|
||||||
@ -48,12 +46,10 @@ protected:
|
|||||||
using bsoncxx::builder::stream::finalize;
|
using bsoncxx::builder::stream::finalize;
|
||||||
|
|
||||||
if (client_ != nullptr) {
|
if (client_ != nullptr) {
|
||||||
memory_buf_t formatted;
|
|
||||||
base_sink<Mutex>::formatter_->format(msg, formatted);
|
|
||||||
auto doc = document{}
|
auto doc = document{}
|
||||||
<< "timestamp" << bsoncxx::types::b_date(msg.time) << "level"
|
<< "timestamp" << bsoncxx::types::b_date(msg.time) << "level"
|
||||||
<< level::to_string_view(msg.level).data() << "message"
|
<< level::to_string_view(msg.level).data() << "message"
|
||||||
<< std::string(formatted.begin(), formatted.end())
|
<< std::string(msg.payload.begin(), msg.payload.end())
|
||||||
<< "logger_name"
|
<< "logger_name"
|
||||||
<< std::string(msg.logger_name.begin(), msg.logger_name.end())
|
<< std::string(msg.logger_name.begin(), msg.logger_name.end())
|
||||||
<< "thread_id" << static_cast<int>(msg.thread_id) << finalize;
|
<< "thread_id" << static_cast<int>(msg.thread_id) << finalize;
|
||||||
|
Loading…
Reference in New Issue
Block a user