From: Kefu Chai Date: Tue, 19 Jan 2021 04:16:12 +0000 (+0800) Subject: pybind/mgr: use numeric values of logging level for index X-Git-Tag: v17.1.0~3164^2~12 X-Git-Url: http://git.apps.os.sepia.ceph.com/?a=commitdiff_plain;h=ab0243b31946e058ecb41a2a04aedd8459b89bbb;p=ceph-ci.git pybind/mgr: use numeric values of logging level for index less magic values in code this way Signed-off-by: Kefu Chai --- diff --git a/src/pybind/mgr/mgr_module.py b/src/pybind/mgr/mgr_module.py index 50e750c647b..7da1f3c2474 100644 --- a/src/pybind/mgr/mgr_module.py +++ b/src/pybind/mgr/mgr_module.py @@ -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,