3#include <spdlog/spdlog.h>
19 case spdlog::level::trace:
20 spdlog::trace(
"{} {}", messageStr, addr ==
nullptr ?
"" : addr);
22 case spdlog::level::debug:
23 spdlog::debug(
"{} {}", messageStr, addr ==
nullptr ?
"" : addr);
25 case spdlog::level::info:
26 spdlog::info(
"{} {}", messageStr, addr ==
nullptr ?
"" : addr);
28 case spdlog::level::warn:
29 spdlog::warn(
"{} {}", messageStr, addr ==
nullptr ?
"" : addr);
31 case spdlog::level::err:
32 spdlog::error(
"{} {}", messageStr, addr ==
nullptr ?
"" : addr);
34 case spdlog::level::critical:
35 spdlog::critical(
"{} {}", messageStr, addr ==
nullptr ?
"" : addr);
38 spdlog::warn(
"Unknown log level {} {} {}", messageStr, addr ==
nullptr ?
"" : addr, level);
47 on_event(
"Connected", spdlog::level::info, addr_);
52 on_event(
"Connect delayed", spdlog::level::debug, addr_);
57 on_event(
"Connect retried", spdlog::level::debug, addr_);
62 on_event(
"Listening", spdlog::level::debug, addr_);
67 on_event(
"Bind failed", spdlog::level::warn, addr_);
72 on_event(
"Accepted", spdlog::level::info, addr_);
77 on_event(
"Accept failed", spdlog::level::warn, addr_);
82 on_event(
"Closed", spdlog::level::debug, addr_);
87 on_event(
"Close failed", spdlog::level::warn, addr_);
92 on_event(
"Disconnected", spdlog::level::info, addr_);
95#if ZMQ_VERSION >= ZMQ_MAKE_VERSION(4, 3, 0) || \
96 (defined(ZMQ_BUILD_DRAFT_API) && ZMQ_VERSION >= ZMQ_MAKE_VERSION(4, 2, 3))
99 on_event(
"Handshake failed (no detail)", spdlog::level::warn, addr_);
104 on_event(
"Handshake failed (protocol)", spdlog::level::warn, addr_);
109 on_event(
"Handshake failed (auth)", spdlog::level::warn, addr_);
114 on_event(
"Handshake succeeded", spdlog::level::info, addr_);
117#elif defined(ZMQ_BUILD_DRAFT_API) && ZMQ_VERSION >= ZMQ_MAKE_VERSION(4, 2, 1)
118void ZeroMQMonitor::on_event_handshake_failed(
const zmq_event_t & ,
const char *addr_)
120 on_event(
"Handshake failed", spdlog::level::warn, addr_);
123void ZeroMQMonitor::on_event_handshake_succeed(
const zmq_event_t & ,
const char *addr_)
125 on_event(
"Handshake succeed", spdlog::level::info, addr_);
131 on_event(
"Unknown event", spdlog::level::warn, addr_);
136 if (socket ==
nullptr)
138 throw std::invalid_argument(
"ZeroMQ socket to monitor is nullptr");
141 init(*socket, monitorAddress);
148#ifdef ZMQ_EVENT_MONITOR_STOPPED
159 spdlog::info(
"Monitor stopped");
constexpr int EVENT_CHECK_TIMEOUT_MS
void on_event_unknown(const zmq_event_t &, const char *addr_) override
void on_event_connect_retried(const zmq_event_t &, const char *addr_) override
void on_event_disconnected(const zmq_event_t &, const char *addr_) override
void on_event_bind_failed(const zmq_event_t &, const char *addr_) override
void on_event_connect_delayed(const zmq_event_t &, const char *addr_) override
void on_event_listening(const zmq_event_t &, const char *addr_) override
void on_event_closed(const zmq_event_t &, const char *addr_) override
void startMonitoring(zmq::socket_t *socket, const std::string &monitorAddress)
void on_event_connected(const zmq_event_t &, const char *addr_) override
void on_event_handshake_succeeded(const zmq_event_t &, const char *addr_) override
void on_event_accepted(const zmq_event_t &, const char *addr_) override
std::unique_ptr< std::thread > _monitorThread
void on_event_handshake_failed_auth(const zmq_event_t &, const char *addr_) override
void on_event_accept_failed(const zmq_event_t &, const char *addr_) override
static void on_event(const std::string &messageStr, int level, const char *addr=nullptr)
void on_monitor_started() override
void on_event_handshake_failed_no_detail(const zmq_event_t &, const char *addr_) override
void on_event_handshake_failed_protocol(const zmq_event_t &, const char *addr_) override
std::atomic_flag _shouldStop
void on_event_close_failed(const zmq_event_t &, const char *addr_) override