diff options
author | Chris Wilson <chris+github@qwirx.com> | 2008-05-28 12:37:49 +0000 |
---|---|---|
committer | Chris Wilson <chris+github@qwirx.com> | 2008-05-28 12:37:49 +0000 |
commit | e43fdd9d7acacd6d711b7f120e5b477767ad11c1 (patch) | |
tree | 206e3ac0cf4c4dea38fce2a1de754cce94aecebe /lib/common/Logging.cpp | |
parent | 0ed03aa198fedb15283018dff384dfad0dc97c79 (diff) |
Add static Logging::GetNamedLevel() method to return a log level
specified by name as a string.
Diffstat (limited to 'lib/common/Logging.cpp')
-rw-r--r-- | lib/common/Logging.cpp | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/lib/common/Logging.cpp b/lib/common/Logging.cpp index f49ab765..5eec1e81 100644 --- a/lib/common/Logging.cpp +++ b/lib/common/Logging.cpp @@ -179,6 +179,23 @@ void Logging::SetContext(std::string context) sContextSet = true; } +Log::Level Logging::GetNamedLevel(const std::string& rName) +{ + if (rName == "nothing") { return Log::NOTHING; } + else if (rName == "fatal") { return Log::FATAL; } + else if (rName == "error") { return Log::ERROR; } + else if (rName == "warning") { return Log::WARNING; } + else if (rName == "notice") { return Log::NOTICE; } + else if (rName == "info") { return Log::INFO; } + else if (rName == "trace") { return Log::TRACE; } + else if (rName == "everything") { return Log::EVERYTHING; } + else + { + BOX_ERROR("Unknown verbosity level: " << rName); + return Log::INVALID; + } +} + void Logging::ClearContext() { sContextSet = false; @@ -350,6 +367,7 @@ bool Syslog::Log(Log::Level level, const std::string& rFile, switch(level) { case Log::NOTHING: /* fall through */ + case Log::INVALID: /* fall through */ case Log::FATAL: syslogLevel = LOG_CRIT; break; case Log::ERROR: syslogLevel = LOG_ERR; break; case Log::WARNING: syslogLevel = LOG_WARNING; break; |