xcal
基于 C++23 的现代图形渲染引擎
载入中...
搜索中...
未找到
zmqlogsubmitstream.hpp
浏览该文件的文档.
1#pragma once
2#include <string>
3#include <zmq.hpp>
4
5#include "./message.hpp"
6
7namespace xclogger {
9 private:
10 zmq::context_t ctx_{1};
11 zmq::socket_t pub_{ctx_, zmq::socket_type::pub};
12
13 public:
14 ZmqLogSubmitStream(const std::string& addr) {
15 pub_.bind("tcp://127.0.0.1:5555");
16 }
18 auto data = Message::encode(msg);
19 pub_.send(zmq::str_buffer("hello log"), zmq::send_flags::dontwait);
20 ;
21 return *this;
22 }
24 pub_.close();
25 ctx_.close();
26 }
27};
28} // namespace xclogger
29
30#define XCLOG_ENABLE_ZMQLOGSUBMITSTREAM(addr) \
31 XCLOG_SUBMIT_STREAM_INSTENCE_IMPT() { \
32 static ::xclogger::ZmqLogSubmitStream zmq_stream{addr}; \
33 return &zmq_stream; \
34 }
ZmqLogSubmitStream & operator<<(const Message &msg)
ZmqLogSubmitStream(const std::string &addr)
static std::vector< char > encode(const Message &msg)
Definition message.hpp:30