summaryrefslogtreecommitdiff
path: root/lib/common/Logging.cpp
diff options
context:
space:
mode:
authorChris Wilson <chris+github@qwirx.com>2008-05-28 12:37:49 +0000
committerChris Wilson <chris+github@qwirx.com>2008-05-28 12:37:49 +0000
commite43fdd9d7acacd6d711b7f120e5b477767ad11c1 (patch)
tree206e3ac0cf4c4dea38fce2a1de754cce94aecebe /lib/common/Logging.cpp
parent0ed03aa198fedb15283018dff384dfad0dc97c79 (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.cpp18
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;