From: Sage Weil Date: Mon, 3 Nov 2014 09:18:24 +0000 (-0800) Subject: commong/LogEntry: string_to_clog_type X-Git-Tag: v0.89~42^2~6 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=4f409750138e8a9de184b4cc77c07f45f1b16222;p=ceph.git commong/LogEntry: string_to_clog_type Signed-off-by: Sage Weil --- diff --git a/src/common/LogEntry.cc b/src/common/LogEntry.cc index f3fb989cc89..75d22d904bb 100644 --- a/src/common/LogEntry.cc +++ b/src/common/LogEntry.cc @@ -61,6 +61,28 @@ int clog_type_to_syslog_level(clog_type t) } } +clog_type string_to_clog_type(const string& s) +{ + if (boost::iequals(s, "debug") || + boost::iequals(s, "dbg")) + return CLOG_DEBUG; + if (boost::iequals(s, "info") || + boost::iequals(s, "inf")) + return CLOG_INFO; + if (boost::iequals(s, "warning") || + boost::iequals(s, "warn") || + boost::iequals(s, "wrn")) + return CLOG_WARN; + if (boost::iequals(s, "error") || + boost::iequals(s, "err")) + return CLOG_ERROR; + if (boost::iequals(s, "security") || + boost::iequals(s, "sec")) + return CLOG_SEC; + + return CLOG_UNKNOWN; +} + int string_to_syslog_level(string s) { if (boost::iequals(s, "debug")) diff --git a/src/common/LogEntry.h b/src/common/LogEntry.h index c6c16b25e27..63badffbfb7 100644 --- a/src/common/LogEntry.h +++ b/src/common/LogEntry.h @@ -30,6 +30,7 @@ typedef enum { CLOG_SEC = 2, CLOG_WARN = 3, CLOG_ERROR = 4, + CLOG_UNKNOWN = -1, } clog_type; static const std::string CLOG_CHANNEL_NONE = "none"; @@ -42,6 +43,7 @@ static const std::string CLOG_CHANNEL_AUDIT = "audit"; */ int clog_type_to_syslog_level(clog_type t); +clog_type string_to_clog_type(const string& s); int string_to_syslog_level(string s); int string_to_syslog_facility(string s);