SOLA
Loading...
Searching...
No Matches
natter_logger_ns3.h
1// Copyright 2023 The SOLA authors
2//
3// This file is part of DAISI.
4//
5// DAISI is free software: you can redistribute it and/or modify it under the terms of the GNU
6// General Public License as published by the Free Software Foundation; version 2.
7//
8// DAISI is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even
9// the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
10// Public License for more details.
11//
12// You should have received a copy of the GNU General Public License along with DAISI. If not, see
13// <https://www.gnu.org/licenses/>.
14//
15// SPDX-License-Identifier: GPL-2.0-only
16
17#ifndef DAISI_NATTER_NS3_NATTER_LOGGER_NS3_H_
18#define DAISI_NATTER_NS3_NATTER_LOGGER_NS3_H_
19
20#include <ctime>
21#include <unordered_map>
22
23#include "logging/definitions.h"
24#include "natter/logger_interface.h"
25#include "natter_mode.h"
26
27namespace natter::logging {
28
30public:
31 NatterLoggerNs3(LogDeviceApp log_device_application, LogFunction log, LogEvent log_event);
32
33 // natter-ns3 specific logging functions
34 void logNewNetworkPeer(solanet::UUID uuid, const std::string &ip, uint16_t port, int level,
35 int number) final;
36
37 void logNs3PeerConnection(uint64_t timestamp, bool active, solanet::UUID node_uuid,
38 solanet::UUID new_node_uuid);
39
40 void logReceivedMessages(solanet::UUID node_uuid, solanet::UUID initial_sender,
41 solanet::UUID message, uint32_t round_) final;
42
43 void logNatterEvent(uint16_t event_type, solanet::UUID event_id);
44
45 // TODO Refactor to other class
46 void setApplicationUUID(const solanet::UUID &app_uuid) final {
47 LoggerInterface::uuid_ = solanet::uuidToString(app_uuid);
48 log_device_application_(uuid_);
49 }
50
51 ~NatterLoggerNs3() override;
52
53private:
54 enum class Mode : uint16_t { kReceive, kSend };
55
56 enum class MsgType : uint16_t { kUnknown, kFullMsg };
57
58 void logCritical(const std::string &msg) const final;
59
60 void logWarning(const std::string &msg) const final;
61
62 void logInfo(const std::string &msg) const final;
63
64 void logDebug(const std::string &msg) const final;
65
66 void logNewPeer(const std::string &ip, uint16_t port, solanet::UUID uuid,
67 const std::string &topic) const final;
68
69 void logRemovePeer(const std::string &ip, uint16_t port, solanet::UUID uuid,
70 const std::string &topic) const final;
71
72 void logNewMessage(const std::string &topic, const std::string &msg,
73 solanet::UUID msg_uuid) final;
74
75 void logSendFullMsg(solanet::UUID msg_uuid, solanet::UUID uuid, solanet::UUID own_uuid) final;
76
77 void logReceiveFullMsg(solanet::UUID msg_uuid, solanet::UUID sender,
78 solanet::UUID own_uuid) final;
79
80 void logSendReceive(solanet::UUID msg_uuid, solanet::UUID sender, solanet::UUID own_uuid,
81 MsgType type, Mode mode);
82
83 void logMinhcastBroadcast(solanet::UUID msg_id, uint32_t level, uint32_t number,
84 uint32_t forward_up_limit, uint32_t forward_down_limit) final;
85
86 // TODO Refactor to other class
87 LogDeviceApp log_device_application_;
88 LogFunction log_;
89 LogEvent log_event_;
90};
91
92} // namespace natter::logging
93
94#endif // NATTER_NS3_LOGGER_H_
Definition logger_interface.h:25
Definition natter_logger_ns3.h:29
void setApplicationUUID(const solanet::UUID &app_uuid) final
Definition natter_logger_ns3.h:46
void logNatterEvent(uint16_t event_type, solanet::UUID event_id)
Don't forget to use .c_str() to convert std::string into a char array.
Definition natter_logger_ns3.cpp:33