Commit ceccbb60 authored by Steffen Vogel's avatar Steffen Vogel 🎅🏼
Browse files

log: throw exception for unknown log levels

parent 8de147f0
......@@ -20,6 +20,9 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*********************************************************************************/
#include <list>
#include <algorithm>
#include <spdlog/sinks/stdout_color_sinks.h>
#include <spdlog/sinks/syslog_sink.h>
#include <spdlog/sinks/basic_file_sink.h>
......@@ -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<std::string> 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);
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment