9 #include <framework/logging/LogConnectionUDP.h>
10 #include <framework/logging/LogMessage.h>
12 using namespace boost::asio;
13 using boost::asio::ip::udp;
17 LogConnectionUDP::LogConnectionUDP(
const std::string& hostname,
unsigned short port) : m_socket(m_ioservice)
20 ip::udp::resolver::query udpquery(udp::v4(), hostname, std::to_string(port));
34 const std::string& jsonMessage = message.toJSON(
true);
36 boost::system::error_code err;
38 const bool sent = err.value() != 0;
~LogConnectionUDP() override
Close the socket on destruction.
boost::asio::ip::udp::endpoint m_remoteEndpoint
the remote endpoint we send to
boost::asio::ip::udp::socket m_socket
the socket to the UDP server
bool sendMessage(const LogMessage &message) final
Send the log message as JSON to the UDP server.
bool isConnected() final
there is no way to check if a UDP connection is fine, so we just return True always
boost::asio::io_service m_ioservice
asio service for handling the requests
Abstract base class for different kinds of events.