]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
commong/LogEntry: string_to_clog_type
authorSage Weil <sage@redhat.com>
Mon, 3 Nov 2014 09:18:24 +0000 (01:18 -0800)
committerSage Weil <sage@redhat.com>
Wed, 5 Nov 2014 09:06:02 +0000 (01:06 -0800)
Signed-off-by: Sage Weil <sage@redhat.com>
src/common/LogEntry.cc
src/common/LogEntry.h

index f3fb989cc8945f457c002a440ff7f633dd8f3f50..75d22d904bb0fd330fc0d4074e6b23c46665a5a9 100644 (file)
@@ -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"))
index c6c16b25e2789d54e3cea4d218226e96eabbd304..63badffbfb785df88b1ca5441ad3de88059a5766 100644 (file)
@@ -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);