diff --git a/src/anbox/daemon.cpp b/src/anbox/daemon.cpp index d246d7c432c1a498bc8d1cddacecb51c7d07076a..6bb4e844e0ed7c0e9e953635d5879e1b4b0d7fa5 100644 --- a/src/anbox/daemon.cpp +++ b/src/anbox/daemon.cpp @@ -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 &arguments) try { diff --git a/src/anbox/logger.cpp b/src/anbox/logger.cpp index 8dd78668806d2371d317f0a50d7079e02cfee0be..f59803d47d3e70eb7bb07698fa941634b703e32a 100644 --- a/src/anbox/logger.cpp +++ b/src/anbox/logger.cpp @@ -107,7 +107,7 @@ void SetInstance(const std::shared_ptr& 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, diff --git a/src/anbox/logger.h b/src/anbox/logger.h index 7a177eb68674190cd2ac958350ee3257a30aa07e..6e797b65f76575c8129d43609f4546baf297940e 100644 --- a/src/anbox/logger.h +++ b/src/anbox/logger.h @@ -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,