21 #define SPDLOG_HEADER_ONLY
22 #include <spdlog/common.h>
23 #include <spdlog/details/log_msg.h>
24 #include <spdlog/sinks/base_sink.h>
31 template <
class Mutex>
36 void (*flush)() =
nullptr)
43 void sink_it_(
const details::log_msg& msg)
override
45 spdlog::memory_buf_t formatted;
46 base_sink<Mutex>::formatter_->format(msg, formatted);
47 std::string msg_string = fmt::to_string(formatted);
50 _callback(
static_cast<int>(msg.level), msg_string.c_str());
52 std::cout << msg_string;
61 std::cout << std::flush;
Definition: callbackSink.hpp:32
void sink_it_(const details::log_msg &msg) override
Definition: callbackSink.hpp:43
void set_callback(LogCallback callback)
Definition: callbackSink.hpp:39
LogCallback _callback
Definition: callbackSink.hpp:65
CallbackSink(std::string tag="spdlog", LogCallback callback=nullptr, void(*flush)()=nullptr)
Definition: callbackSink.hpp:34
void(* _flush)()
Definition: callbackSink.hpp:66
void flush_() override
Definition: callbackSink.hpp:56
void set_flush(void(*flush)())
Definition: callbackSink.hpp:40
void(* LogCallback)(int lvl, const char *msg)
Definition: callbackSink.hpp:29
Definition: callbackSink.hpp:26