log: allow lowercase LOG_LEVEL values
This commit is contained in:
parent
9bd80ab85c
commit
25f6cd635b
6
log.cpp
6
log.cpp
@ -58,8 +58,8 @@ level_to_string (level_t l) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
level_t
|
static level_t
|
||||||
string_to_level (const string &name) {
|
string_to_level (string name) {
|
||||||
static const map <string, level_t> NAME_LEVELS = {
|
static const map <string, level_t> NAME_LEVELS = {
|
||||||
{ "EMERGENCY", EMERGENCY },
|
{ "EMERGENCY", EMERGENCY },
|
||||||
{ "ALERT", ALERT },
|
{ "ALERT", ALERT },
|
||||||
@ -73,6 +73,8 @@ string_to_level (const string &name) {
|
|||||||
{ "DEBUG", DEBUG }
|
{ "DEBUG", DEBUG }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
std::transform (name.cbegin (), name.cend (), name.begin (), ::toupper);
|
||||||
|
|
||||||
auto pos = NAME_LEVELS.find (name);
|
auto pos = NAME_LEVELS.find (name);
|
||||||
if (pos == NAME_LEVELS.end ())
|
if (pos == NAME_LEVELS.end ())
|
||||||
throw std::range_error (name);
|
throw std::range_error (name);
|
||||||
|
Loading…
Reference in New Issue
Block a user