Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mongo sink improvements #2519

Merged
merged 8 commits into from
Oct 19, 2022
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
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.
  • Loading branch information
Sandor Magyar authored and Sandor Magyar committed Oct 17, 2022
commit 0145223be1c3b115e562603881af2832505fe496
3 changes: 2 additions & 1 deletion include/spdlog/sinks/mongo_sink.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,8 @@ class mongo_sink : public base_sink<Mutex>

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;
Expand Down