Use std::array for level_to_string
* Explicitly uses the correct size. * Remove some 'unsafe loop optimisation' warnings
This commit is contained in:
parent
88c86a40a7
commit
3548dcd675
7
log.cpp
7
log.cpp
@ -23,6 +23,7 @@
|
|||||||
#include "debug.hpp"
|
#include "debug.hpp"
|
||||||
#include "types.hpp"
|
#include "types.hpp"
|
||||||
|
|
||||||
|
#include <array>
|
||||||
#include <ctime>
|
#include <ctime>
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
#include <map>
|
#include <map>
|
||||||
@ -43,7 +44,7 @@ const string&
|
|||||||
level_to_string (level_t l) {
|
level_to_string (level_t l) {
|
||||||
check_level (l);
|
check_level (l);
|
||||||
|
|
||||||
static const std::string level_names[] = {
|
static const std::array <std::string, NUM_LEVELS> LEVEL_NAMES ({{
|
||||||
"EMERGENCY",
|
"EMERGENCY",
|
||||||
"ALERT",
|
"ALERT",
|
||||||
"CRITICAL",
|
"CRITICAL",
|
||||||
@ -52,9 +53,9 @@ level_to_string (level_t l) {
|
|||||||
"NOTICE",
|
"NOTICE",
|
||||||
"INFO",
|
"INFO",
|
||||||
"DEBUG"
|
"DEBUG"
|
||||||
};
|
}});
|
||||||
|
|
||||||
return level_names[l];
|
return LEVEL_NAMES[l];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user