Skip to content

Commit 27527ad

Browse files
committed
Add critical severity level between fatal and error
1 parent f3d68fb commit 27527ad

File tree

7 files changed

+16
-8
lines changed

7 files changed

+16
-8
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,7 @@ where severity level is one of the following:
100100
"important",
101101
"alarm",
102102
"error",
103+
"critical",
103104
"fatal",
104105
```
105106

logger/Logger.cxx

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/********************************************************************************
2-
* Copyright (C) 2014-2019 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH *
2+
* Copyright (C) 2014-2025 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH *
33
* *
44
* This software is distributed under the terms of the *
55
* GNU Lesser General Public Licence (LGPL) version 3, *
@@ -69,6 +69,7 @@ const unordered_map<string_view, Severity> Logger::fSeverityMap =
6969
{ {"NOLOG"}, Severity::nolog },
7070
{ {"fatal"}, Severity::fatal },
7171
{ {"FATAL"}, Severity::fatal },
72+
{ {"critical"}, Severity::critical },
7273
{ {"error"}, Severity::error },
7374
{ {"ERROR"}, Severity::error },
7475
{ {"alarm"}, Severity::alarm },
@@ -96,7 +97,7 @@ const unordered_map<string_view, Severity> Logger::fSeverityMap =
9697
{ {"TRACE"}, Severity::trace }
9798
};
9899

99-
const array<string_view, 15> Logger::fSeverityNames =
100+
const array<string_view, 16> Logger::fSeverityNames =
100101
{
101102
{
102103
"NOLOG",
@@ -113,6 +114,7 @@ const array<string_view, 15> Logger::fSeverityNames =
113114
"IMPORTANT",
114115
"ALARM",
115116
"ERROR",
117+
"CRITICAL",
116118
"FATAL"
117119
}
118120
};
@@ -289,6 +291,7 @@ string Logger::GetColoredSeverityString(Severity severity)
289291
switch (severity) {
290292
case Severity::nolog: return "\033[01;39mNOLOG\033[0m"; break;
291293
case Severity::fatal: return "\033[01;31mFATAL\033[0m"; break;
294+
case Severity::critical: return "\033[01;31mCRITICAL\033[0m"; break;
292295
case Severity::error: return "\033[01;31mERROR\033[0m"; break;
293296
case Severity::alarm: return "\033[01;33mALARM\033[0m"; break;
294297
case Severity::important: return "\033[01;32mIMPORTANT\033[0m"; break;

logger/Logger.h

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/********************************************************************************
2-
* Copyright (C) 2014-2019 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH *
2+
* Copyright (C) 2014-2025 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH *
33
* *
44
* This software is distributed under the terms of the *
55
* GNU Lesser General Public Licence (LGPL) version 3, *
@@ -67,7 +67,8 @@ enum class Severity : int
6767
important = 11,
6868
alarm = 12,
6969
error = 13,
70-
fatal = 14,
70+
critical = 14,
71+
fatal = 15,
7172
// aliases
7273
warning = warn,
7374
// backwards-compatibility
@@ -325,7 +326,7 @@ class Logger
325326

326327
static const std::unordered_map<std::string_view, Verbosity> fVerbosityMap;
327328
static const std::unordered_map<std::string_view, Severity> fSeverityMap;
328-
static const std::array<std::string_view, 15> fSeverityNames;
329+
static const std::array<std::string_view, 16> fSeverityNames;
329330
static const std::array<std::string_view, 9> fVerbosityNames;
330331

331332
// protection for use after static destruction took place

test/cycle.cxx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/********************************************************************************
2-
* Copyright (C) 2015-2020 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH *
2+
* Copyright (C) 2015-2025 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH *
33
* *
44
* This software is distributed under the terms of the *
55
* GNU Lesser General Public Licence (LGPL) version 3, *
@@ -38,7 +38,7 @@ int main()
3838
Logger::SetConsoleSeverity(Severity::fatal);
3939
cout << "initial severity >" << Logger::GetConsoleSeverity() << "<" << endl << endl;
4040

41-
array<Severity, 15> severitiesUp{{ Severity::nolog, Severity::trace, Severity::debug4, Severity::debug3, Severity::debug2, Severity::debug1, Severity::debug, Severity::detail, Severity::info, Severity::state, Severity::warn, Severity::important, Severity::alarm, Severity::error, Severity::fatal }};
41+
array<Severity, 16> severitiesUp{{ Severity::nolog, Severity::trace, Severity::debug4, Severity::debug3, Severity::debug2, Severity::debug1, Severity::debug, Severity::detail, Severity::info, Severity::state, Severity::warn, Severity::important, Severity::alarm, Severity::error, Severity::critical, Severity::fatal }};
4242
#ifdef FAIR_MIN_SEVERITY
4343
for (unsigned int i = static_cast<int>(Severity::FAIR_MIN_SEVERITY); i < severitiesUp.size(); ++i) {
4444
#else
@@ -57,7 +57,7 @@ int main()
5757
Logger::SetConsoleSeverity(Severity::fatal);
5858
cout << "initial severity >" << Logger::GetConsoleSeverity() << "<" << endl << endl;
5959

60-
array<Severity, 15> severitiesDown{{ Severity::error, Severity::alarm, Severity::important, Severity::warn, Severity::state, Severity::info, Severity::detail, Severity::debug, Severity::debug1, Severity::debug2, Severity::debug3, Severity::debug4, Severity::trace, Severity::nolog, Severity::fatal }};
60+
array<Severity, 16> severitiesDown{{ Severity::critical, Severity::error, Severity::alarm, Severity::important, Severity::warn, Severity::state, Severity::info, Severity::detail, Severity::debug, Severity::debug1, Severity::debug2, Severity::debug3, Severity::debug4, Severity::trace, Severity::nolog, Severity::fatal }};
6161
#ifdef FAIR_MIN_SEVERITY
6262
for (unsigned int i = 0; i < severitiesDown.size() - static_cast<int>(Severity::FAIR_MIN_SEVERITY) - 1; ++i) {
6363
#else

test/logger.cxx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ void printEverySeverity()
3131
LOG(important) << "important message, counter: " << i++;
3232
LOG(alarm) << "alarm message, counter: " << i++;
3333
LOG(error) << "error message, counter: " << i++;
34+
LOG(critical) << "critical message, counter: " << i++;
3435
LOG(fatal) << "fatal message, counter: " << i++;
3536
}
3637

test/nolog.cxx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ void printEverySeverity()
2727
LOG(important) << "important message ";
2828
LOG(alarm) << "alarm message ";
2929
LOG(error) << "error message ";
30+
LOG(critical) << "critical message ";
3031
}
3132

3233
void silentlyPrintAllVerbositiesWithSeverity(Severity sev)

test/severity.cxx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ uint32_t printEverySeverity(uint32_t i)
3434
LOG(important) << "important message, counter: " << i++;
3535
LOG(alarm) << "alarm message, counter: " << i++;
3636
LOG(error) << "error message, counter: " << i++;
37+
LOG(critical) << "critical message, counter: " << i++;
3738
LOG(fatal) << "fatal message, counter: " << i++;
3839

3940
return i;

0 commit comments

Comments
 (0)