提交 ef5cdf17 编写于 作者: S Simon Fels

Rename SetSeverity to SetSeverityFromString and check for valid severity

上级 9646a5fb
......@@ -43,8 +43,8 @@ Daemon::Daemon()
Log().Init(anbox::Logger::Severity::kWarning);
const auto log_level = utils::get_env_value("ANBOX_LOG_LEVEL", "");
if (!log_level.empty())
Log().SetSeverity(log_level);
if (!log_level.empty() || !Log().SetSeverityFromString(log_level))
WARNING("Failed to set logging severity to '%s'", log_level);
}
int Daemon::Run(const std::vector<std::string> &arguments) try {
......
......@@ -107,7 +107,7 @@ void SetInstance(const std::shared_ptr<anbox::Logger>& logger) {
}
namespace anbox {
void Logger::SetSeverity(const std::string& severity) {
bool Logger::SetSeverityFromString(const std::string& severity) {
if (severity == "trace")
SetSeverity(Severity::kTrace);
else if (severity == "debug")
......@@ -120,6 +120,9 @@ void Logger::SetSeverity(const std::string& severity) {
SetSeverity(Severity::kError);
else if (severity == "fatal")
SetSeverity(Severity::kFatal);
else
return false;
return true;
}
void Logger::Trace(const std::string& message,
......
......@@ -49,7 +49,7 @@ class Logger : public DoNotCopyOrMove {
virtual void Init(const Severity& severity = Severity::kWarning) = 0;
void SetSeverity(const std::string &severity);
bool SetSeverityFromString(const std::string &severity);
virtual void SetSeverity(const Severity& severity) = 0;
virtual void Log(Severity severity, const std::string& message,
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册