mirror of
https://github.com/FairRootGroup/FairLogger.git
synced 2025-10-13 08:41:12 +00:00
Add 'alarm' and 'important' severities
This commit is contained in:
parent
13ebedca3d
commit
b2dfdd1768
|
@ -96,6 +96,8 @@ where severity level is one of the following:
|
|||
"info",
|
||||
"state",
|
||||
"warn",
|
||||
"important",
|
||||
"alarm",
|
||||
"error",
|
||||
"fatal",
|
||||
```
|
||||
|
|
|
@ -67,6 +67,8 @@ const unordered_map<string, Severity> Logger::fSeverityMap =
|
|||
{ "NOLOG", Severity::nolog },
|
||||
{ "error", Severity::error },
|
||||
{ "ERROR", Severity::error },
|
||||
{ "alarm", Severity::alarm },
|
||||
{ "important", Severity::important },
|
||||
{ "warn", Severity::warn },
|
||||
{ "WARN", Severity::warn },
|
||||
{ "warning", Severity::warn },
|
||||
|
@ -89,7 +91,7 @@ const unordered_map<string, Severity> Logger::fSeverityMap =
|
|||
{ "TRACE", Severity::trace }
|
||||
};
|
||||
|
||||
const array<string, 12> Logger::fSeverityNames =
|
||||
const array<string, 14> Logger::fSeverityNames =
|
||||
{
|
||||
{
|
||||
"NOLOG",
|
||||
|
@ -102,6 +104,8 @@ const array<string, 12> Logger::fSeverityNames =
|
|||
"INFO",
|
||||
"STATE",
|
||||
"WARN",
|
||||
"IMPORTANT",
|
||||
"ALARM",
|
||||
"ERROR",
|
||||
"FATAL"
|
||||
}
|
||||
|
@ -281,6 +285,8 @@ string Logger::GetColoredSeverityString(Severity severity)
|
|||
case Severity::nolog: return "\033[01;39mNOLOG\033[0m"; break;
|
||||
case Severity::fatal: return "\033[01;31mFATAL\033[0m"; break;
|
||||
case Severity::error: return "\033[01;31mERROR\033[0m"; break;
|
||||
case Severity::alarm: return "\033[01;33mALARM\033[0m"; break;
|
||||
case Severity::important: return "\033[01;32mIMPORTANT\033[0m"; break;
|
||||
case Severity::warn: return "\033[01;33mWARN\033[0m"; break;
|
||||
case Severity::state: return "\033[01;35mSTATE\033[0m"; break;
|
||||
case Severity::info: return "\033[01;32mINFO\033[0m"; break;
|
||||
|
|
|
@ -61,9 +61,13 @@ enum class Severity : int
|
|||
info = 7,
|
||||
state = 8,
|
||||
warn = 9,
|
||||
error = 10,
|
||||
fatal = 11,
|
||||
// backwards-compatibility:
|
||||
important = 10,
|
||||
alarm = 11,
|
||||
error = 12,
|
||||
fatal = 13,
|
||||
// aliases
|
||||
warning = warn,
|
||||
// backwards-compatibility
|
||||
NOLOG = nolog,
|
||||
TRACE = trace,
|
||||
DEBUG4 = debug4,
|
||||
|
@ -74,7 +78,6 @@ enum class Severity : int
|
|||
INFO = info,
|
||||
STATE = state,
|
||||
WARNING = warn,
|
||||
warning = warn,
|
||||
WARN = warn,
|
||||
ERROR = error,
|
||||
FATAL = fatal
|
||||
|
@ -319,7 +322,7 @@ class Logger
|
|||
|
||||
static const std::unordered_map<std::string, Verbosity> fVerbosityMap;
|
||||
static const std::unordered_map<std::string, Severity> fSeverityMap;
|
||||
static const std::array<std::string, 12> fSeverityNames;
|
||||
static const std::array<std::string, 14> fSeverityNames;
|
||||
static const std::array<std::string, 9> fVerbosityNames;
|
||||
|
||||
// protection for use after static destruction took place
|
||||
|
|
|
@ -38,7 +38,7 @@ int main()
|
|||
Logger::SetConsoleSeverity(Severity::fatal);
|
||||
cout << "initial severity >" << Logger::GetConsoleSeverity() << "<" << endl << endl;
|
||||
|
||||
array<Severity, 12> severitiesUp{{ Severity::nolog, Severity::trace, Severity::debug4, Severity::debug3, Severity::debug2, Severity::debug1, Severity::debug, Severity::info, Severity::state, Severity::warn, Severity::error, Severity::fatal }};
|
||||
array<Severity, 14> severitiesUp{{ Severity::nolog, Severity::trace, Severity::debug4, Severity::debug3, Severity::debug2, Severity::debug1, Severity::debug, Severity::info, Severity::state, Severity::warn, Severity::important, Severity::alarm, Severity::error, Severity::fatal }};
|
||||
#ifdef FAIR_MIN_SEVERITY
|
||||
for (unsigned int i = static_cast<int>(Severity::FAIR_MIN_SEVERITY); i < severitiesUp.size(); ++i) {
|
||||
#else
|
||||
|
@ -57,7 +57,7 @@ int main()
|
|||
Logger::SetConsoleSeverity(Severity::fatal);
|
||||
cout << "initial severity >" << Logger::GetConsoleSeverity() << "<" << endl << endl;
|
||||
|
||||
array<Severity, 12> severitiesDown{{ Severity::error, Severity::warn, Severity::state, Severity::info, Severity::debug, Severity::debug1, Severity::debug2, Severity::debug3, Severity::debug4, Severity::trace, Severity::nolog, Severity::fatal }};
|
||||
array<Severity, 14> severitiesDown{{ Severity::error, Severity::alarm, Severity::important, Severity::warn, Severity::state, Severity::info, Severity::debug, Severity::debug1, Severity::debug2, Severity::debug3, Severity::debug4, Severity::trace, Severity::nolog, Severity::fatal }};
|
||||
#ifdef FAIR_MIN_SEVERITY
|
||||
for (unsigned int i = 0; i < severitiesDown.size() - static_cast<int>(Severity::FAIR_MIN_SEVERITY) - 1; ++i) {
|
||||
#else
|
||||
|
|
|
@ -27,6 +27,8 @@ void printEverySeverity()
|
|||
LOG(info) << "info message, counter: " << i++;
|
||||
LOG(state) << "state message, counter: " << i++;
|
||||
LOG(warn) << "warning message, counter: " << i++;
|
||||
LOG(important) << "important message, counter: " << i++;
|
||||
LOG(alarm) << "alarm message, counter: " << i++;
|
||||
LOG(error) << "error message, counter: " << i++;
|
||||
LOG(fatal) << "fatal message, counter: " << i++;
|
||||
}
|
||||
|
|
|
@ -20,9 +20,11 @@ void printEverySeverity()
|
|||
LOG(debug2) << "debug2 message, counter: ";
|
||||
LOG(debug1) << "debug1 message, counter: ";
|
||||
LOG(debug) << "debug message, counter: ";
|
||||
LOG(info) << "info message, counter: " ;
|
||||
LOG(info) << "info message, counter: ";
|
||||
LOG(state) << "state message, counter: ";
|
||||
LOG(warn) << "warning message, counter: ";
|
||||
LOG(important) << "important message, counter: ";
|
||||
LOG(alarm) << "alarm message, counter: ";
|
||||
LOG(error) << "error message, counter: ";
|
||||
}
|
||||
|
||||
|
|
|
@ -30,6 +30,8 @@ uint32_t printEverySeverity(uint32_t i)
|
|||
LOG(info) << "info message, counter: " << i++;
|
||||
LOG(state) << "state message, counter: " << i++;
|
||||
LOG(warn) << "warning message, counter: " << i++;
|
||||
LOG(important) << "important message, counter: " << i++;
|
||||
LOG(alarm) << "alarm message, counter: " << i++;
|
||||
LOG(error) << "error message, counter: " << i++;
|
||||
LOG(fatal) << "fatal message, counter: " << i++;
|
||||
|
||||
|
@ -45,7 +47,7 @@ void CheckSeverity(Severity severity)
|
|||
|
||||
for (uint32_t i = 0; i < Logger::fSeverityNames.size(); ++i) {
|
||||
if (sev == Severity::nolog) {
|
||||
if (i == 11) {
|
||||
if (i == static_cast<int>(fair::Severity::fatal)) {
|
||||
if (!Logger::Logging(static_cast<Severity>(i))) {
|
||||
throw runtime_error(ToStr("expecting to be logging ", Logger::fSeverityNames.at(i), " during ", sev, ", but it is not."));
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user