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
|
||||
string_to_level (const string &name) {
|
||||
static level_t
|
||||
string_to_level (string name) {
|
||||
static const map <string, level_t> NAME_LEVELS = {
|
||||
{ "EMERGENCY", EMERGENCY },
|
||||
{ "ALERT", ALERT },
|
||||
@ -73,6 +73,8 @@ string_to_level (const string &name) {
|
||||
{ "DEBUG", DEBUG }
|
||||
};
|
||||
|
||||
std::transform (name.cbegin (), name.cend (), name.begin (), ::toupper);
|
||||
|
||||
auto pos = NAME_LEVELS.find (name);
|
||||
if (pos == NAME_LEVELS.end ())
|
||||
throw std::range_error (name);
|
||||
|
Loading…
Reference in New Issue
Block a user