]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
pybind/mgr: use numeric values of logging level for index
authorKefu Chai <kchai@redhat.com>
Tue, 19 Jan 2021 04:16:12 +0000 (12:16 +0800)
committerSebastian Wagner <sebastian.wagner@suse.com>
Fri, 29 Jan 2021 12:42:38 +0000 (13:42 +0100)
less magic values in code this way

Signed-off-by: Kefu Chai <kchai@redhat.com>
(cherry picked from commit ab0243b31946e058ecb41a2a04aedd8459b89bbb)

src/pybind/mgr/mgr_module.py

index 50e750c647b58902c13cc51dffb21a2c57629183..7da1f3c24749db8a5cdcc6f9557b8442121ddd49 100644 (file)
@@ -531,13 +531,13 @@ class ClusterLogHandler(logging.Handler):
 
     def emit(self, record: logging.LogRecord) -> None:
         levelmap = {
-            'DEBUG': MgrModule.ClusterLogPrio.DEBUG,
-            'INFO': MgrModule.ClusterLogPrio.INFO,
-            'WARNING': MgrModule.ClusterLogPrio.WARN,
-            'ERROR': MgrModule.ClusterLogPrio.ERROR,
-            'CRITICAL': MgrModule.ClusterLogPrio.ERROR,
+            logging.DEBUG: MgrModule.ClusterLogPrio.DEBUG,
+            logging.INFO: MgrModule.ClusterLogPrio.INFO,
+            logging.WARNING: MgrModule.ClusterLogPrio.WARN,
+            logging.ERROR: MgrModule.ClusterLogPrio.ERROR,
+            logging.CRITICAL: MgrModule.ClusterLogPrio.ERROR,
         }
-        level = levelmap[record.levelname]
+        level = levelmap[record.levelno]
         if record.levelno >= self.level:
             self._module.cluster_log(self._module.module_name,
                                      level,