Belle II Software development
LogConnectionUDP.h
1/**************************************************************************
2 * basf2 (Belle II Analysis Software Framework) *
3 * Author: The Belle II Collaboration *
4 * *
5 * See git log for contributors and copyright holders. *
6 * This file is licensed under LGPL-3.0, see LICENSE.md. *
7 **************************************************************************/
8#pragma once
9
10#include <framework/logging/LogConnectionBase.h>
11#include <boost/asio.hpp>
12
13namespace Belle2 {
21 class LogConnectionUDP final: public LogConnectionBase {
22 public:
24 LogConnectionUDP(const std::string& hostname, unsigned short port);
26 ~LogConnectionUDP() override;
28 bool sendMessage(const LogMessage& message) final;
30 bool isConnected() final;
31 private:
33 boost::asio::io_service m_ioservice;
35 boost::asio::ip::udp::socket m_socket;
37 boost::asio::ip::udp::endpoint m_remoteEndpoint;
38 };
40}
Abstract base class for the different types of log connections.
Log Connection to send the log message as JSON to a UDP server.
~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
The LogMessage class.
Definition: LogMessage.h:29
Abstract base class for different kinds of events.