diff --git a/simgear/debug/logstream.cxx b/simgear/debug/logstream.cxx index 5b736eff..e459a569 100644 --- a/simgear/debug/logstream.cxx +++ b/simgear/debug/logstream.cxx @@ -451,7 +451,7 @@ public: } } - virtual void run() + void run() override { while (1) { LogEntry entry(m_entries.pop()); @@ -737,6 +737,16 @@ logstream::set_log_classes( sgDebugClass c) d->setLogLevels(c, d->m_logPriority); } +sgDebugPriority logstream::priorityFromString(const std::string& s) +{ + if (s == "bulk") return SG_BULK; + if (s == "debug") return SG_DEBUG; + if (s == "info") return SG_INFO; + if (s == "warn") return SG_WARN; + if (s == "alert") return SG_ALERT; + + throw std::invalid_argument("Couldn't parse log prioirty:" + s); +} logstream& sglog() diff --git a/simgear/debug/logstream.hxx b/simgear/debug/logstream.hxx index 201d2160..fef41d05 100644 --- a/simgear/debug/logstream.hxx +++ b/simgear/debug/logstream.hxx @@ -105,6 +105,11 @@ public: sgDebugPriority get_log_priority() const; + /** + @brief convert a string value to a log prioirty. + throws std::invalid_argument if the string is not valid + */ + static sgDebugPriority priorityFromString(const std::string& s); /** * set developer mode on/off. In developer mode, SG_DEV_WARN messags * are treated as warnings. In normal (non-developer) mode they are