-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathLogging.cpp
75 lines (62 loc) · 1.74 KB
/
Logging.cpp
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
/*
* Logging.cpp
*
* Created on: Dec 10, 2016
* Author: louis
*/
#include "Logging.h"
namespace SLM {
const std::string LL_NONE = "none";
const std::string LL_INFO = "info";
const std::string LL_VERBOSE = "verbose";
const std::string LL_PATTERN = "pattern";
const std::string LL_SUBPATTERN = "subpattern";
const std::string LL_ALL = "all";
std::string Logging::toString(LoggingLevel debugLevel) const
{
switch (debugLevel) {
case LoggingLevel::NONE:
return LL_NONE;
case LoggingLevel::PATTERN:
return LL_PATTERN;
case LoggingLevel::SUBPATTERN:
return LL_SUBPATTERN;
case LoggingLevel::ALL:
return LL_ALL;
case LoggingLevel::VERBOSE:
return LL_VERBOSE;
case LoggingLevel::INFO:
return LL_INFO;
default:
return "unknown";
}
}
std::string Logging::toString() const
{
return toString(loggingLevel);
}
LoggingLevel Logging::get() const
{
std::cout << "RETURN " << toString(loggingLevel) << std::endl;
return loggingLevel;
}
void Logging::set(LoggingLevel level)
{
loggingLevel = level;
std::cout << "1Level set to " << toString(loggingLevel) << std::endl;
}
void Logging::set(const std::string& level)
{
if(level == LL_PATTERN) loggingLevel = LoggingLevel::PATTERN;
else if(level == LL_SUBPATTERN) loggingLevel = LoggingLevel::SUBPATTERN;
else if(level == LL_ALL) loggingLevel = LoggingLevel::ALL;
else if(level == LL_INFO) loggingLevel = LoggingLevel::INFO;
else if(level == LL_VERBOSE) loggingLevel = LoggingLevel::VERBOSE;
else if(level == LL_NONE) loggingLevel = LoggingLevel::NONE;
L_V << "Debug output level is " << toString(loggingLevel) << "\n";
}
bool Logging::doLog(LoggingLevel currentLevel) const
{
return currentLevel <= loggingLevel && loggingLevel != LoggingLevel::NONE;
}
} /* namespace SLM */