INFM HIL Interface
Interface between Artery simulation and DuTs
InterfaceLoggerConfig.h
1
26#ifndef SIM_TO_DUT_INTERFACE_INTERFACELOGGERCONFIG_H
27#define SIM_TO_DUT_INTERFACE_INTERFACELOGGERCONFIG_H
28
29#include <string>
30#include <cassert>
31#include <stdexcept>
32#include <boost/serialization/access.hpp>
33#include <boost/serialization/nvp.hpp>
34
35namespace sim_interface {
36
40 enum LOG_LEVEL {
41 NONE, DEBUG, INFO, WARNING, ERROR, CRITICAL
42 };
43
51 public:
52
56 LoggerConfig() = default;
57
73 LoggerConfig(bool enableDebugMode, std::string pathConsoleLog, std::string pathDataLog, int fileBackupCount,
74 LOG_LEVEL fileLogLevel, LOG_LEVEL consoleLogLevel)
75 : enableDebugMode(std::move(enableDebugMode)), pathConsoleLog(std::move(pathConsoleLog)),
76 pathDataLog(std::move(pathDataLog)), fileBackupCount(std::move(fileBackupCount)),
77 fileLogLevel(std::move(fileLogLevel)), consoleLogLevel(std::move(consoleLogLevel)) {
78 if (this->fileBackupCount <= 0) {
79 throw std::invalid_argument("FileBackupCount must be greater 0");
80 }
81 if (this->pathConsoleLog.empty()) {
82 throw std::invalid_argument("The path for consoleLog is not allowed to be empty! May use default configuration.");
83 }
84 if (this->pathConsoleLog.empty()) {
85 throw std::invalid_argument("The path for consoleLog is not allowed to be empty! May use default configuration.");
86 }
87 }
88
89 bool enableDebugMode = false;
90 std::string pathConsoleLog = "/logs/console";
91 std::string pathDataLog = "/logs/data";
92 int fileBackupCount = 10;
93 LOG_LEVEL fileLogLevel = LOG_LEVEL::INFO;
94 LOG_LEVEL consoleLogLevel = LOG_LEVEL::INFO;
95 private:
96 friend class boost::serialization::access;
97
98 template<class Archive>
99 void serialize(Archive &ar, const unsigned int version) {
100 ar & BOOST_SERIALIZATION_NVP(enableDebugMode);
101 ar & BOOST_SERIALIZATION_NVP(pathConsoleLog);
102 ar & BOOST_SERIALIZATION_NVP(pathDataLog);
103 ar & BOOST_SERIALIZATION_NVP(fileBackupCount);
104 ar & BOOST_SERIALIZATION_NVP(fileLogLevel);
105 ar & BOOST_SERIALIZATION_NVP(consoleLogLevel);
106 }
107 };
108
109}
110
111#endif //SIM_TO_DUT_INTERFACE_INTERFACELOGGERCONFIG_H
The logger needs a configuration before it can start logging.
Definition: InterfaceLoggerConfig.h:50
LoggerConfig(bool enableDebugMode, std::string pathConsoleLog, std::string pathDataLog, int fileBackupCount, LOG_LEVEL fileLogLevel, LOG_LEVEL consoleLogLevel)
Definition: InterfaceLoggerConfig.h:73
void serialize(Archive &ar, sim_interface::dut_connector::ConnectorConfig &config, const unsigned int version)
Definition: ConfigSerializer.h:146
Definition: CANConnector.cpp:29
LOG_LEVEL
Definition: InterfaceLoggerConfig.h:40