SOLA
Loading...
Searching...
No Matches
logger.h
1// Copyright The SOLA Contributors
2//
3// Licensed under the MIT License.
4// For details on the licensing terms, see the LICENSE file.
5// SPDX-License-Identifier: MIT
6
7#ifndef NATTER_LOGGER_H_
8#define NATTER_LOGGER_H_
9
10#include <cstdint>
11#include <functional>
12#include <vector>
13
14#include "natter/logger_interface.h"
15#include "solanet/uuid.h"
16
17namespace natter::logging {
21enum class LogLevel { kDebug, kInfo, kWarning, kCritical };
22
26class Logger {
27public:
32 void addLogger(LoggerPtr logger);
33
38 void logCritical(const std::string &msg) const;
39
44 void logWarning(const std::string &msg) const;
45
50 void logInfo(const std::string &msg) const;
51
56 void logDebug(const std::string &msg) const;
57
65 void logNewPeer(const std::string &ip, uint16_t port, solanet::UUID uuid,
66 const std::string &topic) const;
67
75 void logRemovePeer(const std::string &ip, uint16_t port, solanet::UUID uuid,
76 const std::string &topic) const;
77
84 void logNewMessage(const std::string &topic, const std::string &msg, solanet::UUID msg_uuid);
85
92 void logSendFullMsg(solanet::UUID msg_uuid, solanet::UUID uuid, solanet::UUID own_uuid);
93
100 void logReceiveFullMsg(solanet::UUID msg_uuid, solanet::UUID sender, solanet::UUID own_uuid);
101
102 void logMinhcastBroadcast(solanet::UUID msg_id, uint32_t level, uint32_t number,
103 uint32_t forward_up_limit, uint32_t forward_down_limit);
104
105 void logNewNetworkPeer(solanet::UUID uuid, const std::string &ip, uint16_t port, int level,
106 int number);
107
108 void logReceivedMessages(solanet::UUID node_uuid, solanet::UUID initial_sender,
109 solanet::UUID message, uint32_t round);
110
115 LogLevel getLogLevel() const;
116
121 void setLogLevel(LogLevel logLevel);
122
127 bool isLoggingStrings() const;
128
133 void setLogggingStrings(bool log_strings);
134
135private:
140 template <typename LogFunction> void log(LogFunction function) const;
141
142 std::vector<LoggerPtr> logger_list_;
143
144 LogLevel log_level_ = LogLevel::kWarning;
145
146 bool log_strings_ = true;
147};
148} // namespace natter::logging
149
150#endif // NATTER_LOGGER_H_
Definition logger.h:26
void logRemovePeer(const std::string &ip, uint16_t port, solanet::UUID uuid, const std::string &topic) const
Definition logger.cpp:46
void logNewPeer(const std::string &ip, uint16_t port, solanet::UUID uuid, const std::string &topic) const
Definition logger.cpp:38
LogLevel getLogLevel() const
Definition logger.cpp:108
void setLogggingStrings(bool log_strings)
Definition logger.cpp:114
void logDebug(const std::string &msg) const
Definition logger.cpp:33
void addLogger(LoggerPtr logger)
void logCritical(const std::string &msg) const
Definition logger.cpp:19
void logWarning(const std::string &msg) const
Definition logger.cpp:24
void logReceiveFullMsg(solanet::UUID msg_uuid, solanet::UUID sender, solanet::UUID own_uuid)
Definition logger.cpp:69
void logNewMessage(const std::string &topic, const std::string &msg, solanet::UUID msg_uuid)
Definition logger.cpp:54
void setLogLevel(LogLevel logLevel)
Definition logger.cpp:110
void logInfo(const std::string &msg) const
Definition logger.cpp:29
bool isLoggingStrings() const
Definition logger.cpp:112
void logSendFullMsg(solanet::UUID msg_uuid, solanet::UUID uuid, solanet::UUID own_uuid)
Definition logger.cpp:62