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 MINHTON_LOGGING_LOGGER_H_
8#define MINHTON_LOGGING_LOGGER_H_
9
10#include <functional>
11#include <memory>
12#include <vector>
13
14#include "minhton/logging/logger_interface.h"
15
16namespace minhton {
17
18enum class LogLevel { kDebug, kInfo, kWarning, kCritical };
19
20class Logger {
21public:
22 using LoggerPtr = std::shared_ptr<LoggerInterface>;
23
24 void addLogger(LoggerPtr logger);
25
26 void logCritical(const std::string &msg) const;
27 void logWarning(const std::string &msg) const;
28 void logInfo(const std::string &msg) const;
29 void logDebug(const std::string &msg) const;
30
31 void logNodeUninit(const LoggerInfoNodeState &info);
32 void logNodeRunning(const LoggerInfoNodeState &info);
33 void logNodeLeft(const LoggerInfoNodeState &info);
34 void logPhysicalNodeInfo(const LoggerPhysicalNodeInfo &info);
35 void logNode(const LoggerInfoAddNode &info);
36 void logNeighbor(const LoggerInfoAddNeighbor &info);
37 void logEvent(const LoggerInfoAddEvent &info);
38 void logSearchExactTest(const LoggerInfoSearchExact &info);
39 void logTraffic(const MessageLoggingInfo &info);
40 void logContent(const LoggerInfoAddContent &info);
41 void logFindQuery(const LoggerInfoAddFindQuery &info);
42 void logFindQueryResult(const LoggerInfoAddFindQueryResult &info);
43
44 LogLevel getLogLevel() const;
45
46 void setLogLevel(LogLevel logLevel);
47
48 static LogLevel logLevelFromString(const std::string &level);
49
50private:
51 // Command pattern
52 template <typename LogFunction> void logCommand(LogFunction function) const;
53
54 std::vector<LoggerPtr> logger_list_;
55
56 LogLevel log_level_ = LogLevel::kDebug;
57};
58
59} // namespace minhton
60
61#endif
Definition logger.h:20
Definition minhton_watchdog_ns3.cpp:24
Definition message_logging.h:23
Definition logger_interface.h:57
Definition logger_interface.h:46
Definition logger_interface.h:80
Definition logger_interface.h:71
Definition logger_interface.h:39
Definition logger_interface.h:31
Definition logger_interface.h:52
Definition logger_interface.h:19
Definition logger_interface.h:66