18#include <bsoncxx/builder/stream/document.hpp>
19#include <bsoncxx/types.hpp>
20#include <bsoncxx/view_or_value.hpp>
22#include <mongocxx/client.hpp>
23#include <mongocxx/instance.hpp>
24#include <mongocxx/uri.hpp>
28template<
typename Mutex>
36 client_ = spdlog::details::make_unique<mongocxx::client>(mongocxx::uri{uri});
42 throw spdlog_ex(
"Error opening database");
54 using bsoncxx::builder::stream::document;
55 using bsoncxx::builder::stream::finalize;
62 <<
static_cast<int>(msg.
thread_id) << finalize;
84template<
typename Factory = spdlog::synchronous_factory>
88 return Factory::template create<sinks::mongo_sink_mt>(logger_name, db_name, collection_name, uri);
91template<
typename Factory = spdlog::synchronous_factory>
95 return Factory::template create<sinks::mongo_sink_st>(logger_name, db_name, collection_name, uri);
static mongocxx::instance instance_
mongo_sink(const std::string &db_name, const std::string &collection_name, const std::string &uri="mongodb://localhost:27017")
void sink_it_(const details::log_msg &msg) override
std::unique_ptr< mongocxx::client > client_
SPDLOG_INLINE const string_view_t & to_string_view(spdlog::level::level_enum l) SPDLOG_NOEXCEPT
std::shared_ptr< logger > mongo_logger_mt(const std::string &logger_name, const std::string &db_name, const std::string &collection_name, const std::string &uri="mongodb://localhost:27017")
std::shared_ptr< logger > mongo_logger_st(const std::string &logger_name, const std::string &db_name, const std::string &collection_name, const std::string &uri="mongodb://localhost:27017")
log_clock::time_point time
string_view_t logger_name