mirror of
https://git.rwth-aachen.de/acs/public/villas/node/
synced 2025-03-09 00:00:00 +01:00
log: throw exception for unknown log levels
This commit is contained in:
parent
111e1fadac
commit
d6aef7bdd0
1 changed files with 10 additions and 1 deletions
|
@ -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);
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue