ECF 1.5
Logger.h
1#ifndef Logger_h
2#define Logger_h
3
4#include <string>
5#include <vector>
6#include <fstream>
7
8class State;
9typedef boost::shared_ptr<State> StateP;
10
11
15#define ECF_LOG(state, level, msg) \
16 ( ((state)->getLogger()->getLogLevel() >= (level)) ? (state)->getLogger()->log((level), (msg)) : (void) 0 )
17
18
22#define ECF_LOG_ERROR(state, msg) \
23 ( (state)->getLogger()->log(1, (msg)) )
24
25
32class Logger
33{
34public:
35 typedef struct {
36 int logLevel;
37 std::string message;
38 } Log;
39
40 Logger();
41 ~Logger();
42
46 void log(int logLevel, std::string message);
47
52 void saveTo(std::string fileName);
53
58 void saveTo(bool check = false);
59
60 void saveToX(std::string fileName);
61
62 void saveToX();
63
64 void flushLog();
65
70 void setLogFrequency(uint freq);
71
72 void registerParameters(StateP state);
73
77 bool initialize(StateP state);
78
79 bool operate(StateP);
80
81 void closeLog()
82 { logFile_.close(); }
83
84 uint getLogLevel()
85 { return currentLevel_; }
86
87protected:
88 std::vector<Log> logs_;
89 uint currentLevel_;
90 uint logFrequency_;
91 std::string logFileName_;
92 bool bFileDefined_;
93 std::ofstream logFile_;
94 StateP state_;
95};
96typedef boost::shared_ptr<Logger> LoggerP;
97
98#endif
Logging class - handles screen output and file logging.
Definition: Logger.h:33
void flushLog()
deletes current logs
Definition: Logger.cpp:165
void log(int logLevel, std::string message)
Definition: Logger.cpp:63
void saveTo(std::string fileName)
Definition: Logger.cpp:84
bool initialize(StateP state)
Definition: Logger.cpp:33
void setLogFrequency(uint freq)
Definition: Logger.cpp:178
State class - backbone of the framework.
Definition: State.h:39