Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/gabime/spdlog.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSandor Magyar <SMagyar@aphysci.com>2022-10-17 23:15:23 +0300
committerSandor Magyar <SMagyar@aphysci.com>2022-10-17 23:15:23 +0300
commit0145223be1c3b115e562603881af2832505fe496 (patch)
tree3120bb4ee24a6b36eb84590ccc022f5cbee74f74
parentf3b61c70ba4a00712dcec18e9ceef6aea4c79674 (diff)
Add numerical level to Mongo sink for easier queries
Filtering to a certain log level or above, a useful operation, can now be done with an integer comparison as opposed to comparing to a list of strings in the database query.
-rw-r--r--include/spdlog/sinks/mongo_sink.h3
1 files changed, 2 insertions, 1 deletions
diff --git a/include/spdlog/sinks/mongo_sink.h b/include/spdlog/sinks/mongo_sink.h
index d239e928..1338983c 100644
--- a/include/spdlog/sinks/mongo_sink.h
+++ b/include/spdlog/sinks/mongo_sink.h
@@ -56,7 +56,8 @@ protected:
if (client_ != nullptr)
{
- auto doc = document{} << "timestamp" << bsoncxx::types::b_date(msg.time) << "level" << level::to_string_view(msg.level).data()
+ auto doc = document{} << "timestamp" << bsoncxx::types::b_date(msg.time)
+ << "level" << level::to_string_view(msg.level).data() << "level_num" << msg.level
<< "message" << std::string(msg.payload.begin(), msg.payload.end()) << "logger_name"
<< std::string(msg.logger_name.begin(), msg.logger_name.end()) << "thread_id"
<< static_cast<int>(msg.thread_id) << finalize;