/
logger.hpp
82 lines (60 loc) · 1.65 KB
/
logger.hpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
/*
* logger.hpp
*
* Created on: 04.06.2015
* Author: marcus
*/
#ifndef LOGGER_HPP_
#define LOGGER_HPP_
#include <Core/Modelica.h>
class BOOST_EXTENSION_EXPORT_DECL Logger
{
public:
virtual ~Logger();
static Logger* getInstance()
{
if(instance == NULL)
initialize(LogSettings());
return instance;
}
static void initialize(LogSettings settings)
{
if(instance != NULL)
delete instance;
instance = new Logger(settings, true);
}
static void write(std::string msg, LogCategory cat, LogLevel lvl)
{
getInstance()->writeInternal(msg, cat, lvl);
}
static void write(std::string msg, std::pair<LogCategory,LogLevel> mode)
{
return write(msg, mode.first, mode.second);
}
static void setEnabled(bool enabled)
{
getInstance()->setEnabledInternal(enabled);
}
static bool isEnabled()
{
return getInstance()->isEnabledInternal();
}
static std::pair<LogCategory,LogLevel> getLogMode(LogCategory cat, LogLevel lvl)
{
return std::pair<LogCategory, LogLevel>(cat, lvl);
}
bool isOutput(LogCategory cat, LogLevel lvl) const;
bool isOutput(std::pair<LogCategory,LogLevel> mode) const;
protected:
Logger(LogSettings settings, bool enabled);
Logger(bool enabled);
virtual void writeInternal(std::string Msg, LogCategory cat, LogLevel lvl);
virtual void setEnabledInternal(bool enabled);
virtual bool isEnabledInternal();
std::string getPrefix(LogCategory cat, LogLevel lvl) const;
static Logger* instance;
private:
LogSettings _settings;
bool _isEnabled;
};
#endif /* LOGGER_HPP_ */