INFM HIL Interface
Interface between Artery simulation and DuTs
InterfaceLogger.h
1
25#ifndef SIM_TO_DUT_INTERFACE_INTERFACELOGGER_H
26#define SIM_TO_DUT_INTERFACE_INTERFACELOGGER_H
27
28#include "InterfaceLoggerConfig.h"
29#include "../Events/EventVisitor.h"
30#include <string>
31#include "quill/Quill.h"
32#include "../Events/SimEvent.h"
33#include <list>
34#include <filesystem>
35#include <fstream>
36#include <iomanip>
37
38namespace sim_interface {
45 enum LOG_TYPE {
46 CONSOLE_LOG, FILE_LOG
47 };
48
68
69 public:
70
77 static void initializeLogger(const LoggerConfig &con);
78
88 static void logMessage(const std::string &msg, LOG_LEVEL level);
89
99 static void logMessage(const std::string &msg, LOG_LEVEL level, bool writeToFile);
100
107 static void changeLogLevel(LOG_TYPE typ, LOG_LEVEL level);
108
117 static void logEvent(sim_interface::SimEvent event);
118
119 private:
124 static std::string CSV_HEADER;
125
126 // variable to remember if the logger has been initialized yet
127 static bool initialized;
128
129 // define all required loggers
130 static quill::Logger *consoleLogger;
131 static quill::Logger *consoleFileLogger;
132 static quill::Logger *dataLogger;
133
134 // handlers (important to change the log_level
135 static quill::Handler *consoleHandler;
136 static quill::Handler *consoleFileHandler;
137
144 static quill::Handler *buildConsoleHandler(bool enableDebugMode);
145
154 static quill::Handler *buildFileHandler(const std::string &logPath, bool enableDebugMode);
155
164 static quill::Logger *createConsoleLogger(const char *name, bool withFileHandler);
165
173 static quill::Logger *createDataLogger(const std::string &logPath);
174
182 static void logWithLevel(quill::Logger *log, std::string msg, LOG_LEVEL level);
183
189 static quill::Handler *getHandlerType(LOG_TYPE type);
190
196 static std::string getCurrentTimestamp();
197
205 static std::string getLoggingPath(std::string logPath);
206
213 static std::string initializeLoggingPath(const std::string &logPath);
214
227 static void removeOldLogfiles(const std::string &directory, int backupCount);
228 };
229
230}
231
232#endif //SIM_TO_DUT_INTERFACE_INTERFACELOGGER_H
Logger to log to file, console and as structured data csv
Definition: InterfaceLogger.h:67
static void changeLogLevel(LOG_TYPE typ, LOG_LEVEL level)
Definition: InterfaceLogger.cpp:210
static void logMessage(const std::string &msg, LOG_LEVEL level)
Definition: InterfaceLogger.cpp:271
static void initializeLogger(const LoggerConfig &con)
Definition: InterfaceLogger.cpp:44
static void logEvent(sim_interface::SimEvent event)
Definition: InterfaceLogger.cpp:338
The logger needs a configuration before it can start logging.
Definition: InterfaceLoggerConfig.h:50
Event object used to communicate between simulation and DuTs.
Definition: SimEvent.h:47
Definition: CANConnector.cpp:29
LOG_TYPE
Definition: InterfaceLogger.h:45
LOG_LEVEL
Definition: InterfaceLoggerConfig.h:40