16#include "spdlog/sinks/dist_sink.h"
19namespace spdlog::sinks
23template<
typename Mutex>
30 :
filter_(filter, std::regex_constants::ECMAScript){};
48 void sink_it_(const spdlog::details::log_msg& msg)
override
50 spdlog::memory_buf_t formatted_buf;
51 spdlog::sinks::base_sink<Mutex>::formatter_->format(msg, formatted_buf);
52 std::string formatted = fmt::to_string(formatted_buf);
54 if (std::regex_search(formatted,
filter_))
56 spdlog::sinks::dist_sink<Mutex>::sink_it_(msg);
63 #include "spdlog/details/null_mutex.h"
65using dist_filter_sink_mt = dist_filter_sink<std::mutex>;
66using dist_filter_sink_st = dist_filter_sink<spdlog::details::null_mutex>;
Distribution sink (mux) with filter option.
Definition dist_filter_sink.hpp:25
std::regex filter_
String to filter messages for.
Definition dist_filter_sink.hpp:44
dist_filter_sink(dist_filter_sink &&) noexcept=default
Move constructor.
dist_filter_sink(const std::string &filter)
Default constructor.
Definition dist_filter_sink.hpp:29
~dist_filter_sink() override=default
Destructor.
void sink_it_(const spdlog::details::log_msg &msg) override
Function called to process the log message.
Definition dist_filter_sink.hpp:48
dist_filter_sink(const dist_filter_sink &)=delete
Copy constructor.