39 static const std::map<std::string, LogLevel> levels =
52 return levels.at(
tolower(name));
54 catch(
const std::out_of_range &)
56 throw std::invalid_argument(name);
88 stream <<
"MEASUREMENTS";
94 throw std::invalid_argument(
"Unsupported log level");
102 std::stringstream stream;
108 : std::runtime_error{ msg }
113 : std::runtime_error{ msg }, _level{ level }, _msg{ msg }, _context{ std::move(context) }, _combined{
"ERROR: " + msg }
115 if(!_context.empty())
117 _combined +=
"\nCONTEXT:\n" + _context;
128 return _combined.c_str();
std::string to_string(DatasetMode mode)
FileNotFound(const std::string &msg)
Construct error with message.
std::string tolower(std::string string)
Convert string to lower case.
const char * what() const noexceptoverride
LogLevel
Severity of the information.
inline::std::istream & operator>>(::std::istream &stream, DatasetMode &mode)
LogLevel level() const
Severity of the error.
LogLevel log_level_from_name(const std::string &name)
inline::std::ostream & operator<<(::std::ostream &stream, DatasetMode mode)
TestError(const std::string &msg, LogLevel level, std::string context="")
Construct error with severity.