diff --git a/common/lib/log.cpp b/common/lib/log.cpp index a0cb2713b..eaa651d82 100644 --- a/common/lib/log.cpp +++ b/common/lib/log.cpp @@ -20,6 +20,9 @@ * along with this program. If not, see . *********************************************************************************/ +#include +#include + #include #include #include @@ -138,7 +141,13 @@ void Log::setLevel(Level lvl) void Log::setLevel(const std::string &lvl) { - auto level = spdlog::level::from_str(lvl); + std::list l = SPDLOG_LEVEL_NAMES; + + auto it = std::find(l.begin(), l.end(), lvl); + if (it == l.end()) + throw RuntimeError("Invalid log level {}", lvl); + + level = spdlog::level::from_str(lvl); setLevel(level); }