[PATCH] Map our log levels to syslog log levels

Brian C. Lane bcl at redhat.com
Mon Jun 30 22:04:58 UTC 2014


It ends up that syslog doesn't understand levels like ERR and CRIT (and
of course LOCK) so it maps them to WARNING instead of what they really
mean. This checks for the ones anaconda adds and maps them to the
appropriate syslog level.
---
 pyanaconda/anaconda_log.py | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/pyanaconda/anaconda_log.py b/pyanaconda/anaconda_log.py
index 1a48ea9..f7e36a5 100644
--- a/pyanaconda/anaconda_log.py
+++ b/pyanaconda/anaconda_log.py
@@ -67,6 +67,11 @@ def setHandlersLevel(logr, level):
         filter (lambda hdlr: hasattr(hdlr, "autoSetLevel") and hdlr.autoSetLevel, logr.handlers))
 
 class AnacondaSyslogHandler(SysLogHandler):
+    # syslog doesn't understand these level names
+    levelMap = { "ERR": "error",
+                 "CRIT": "critical",
+                 "LOCK": "debug"}
+
     def __init__(self,
                  address=('localhost', SYSLOG_UDP_PORT),
                  facility=SysLogHandler.LOG_USER,
@@ -80,6 +85,10 @@ class AnacondaSyslogHandler(SysLogHandler):
         SysLogHandler.emit(self, record)
         record.msg = original_msg
 
+    def mapPriority(self, level):
+        """Map the priority level to a syslog level """
+        return self.levelMap.get(level, SysLogHandler.mapPriority(self, level))
+
 class AnacondaLog:
     SYSLOG_CFGFILE  = "/etc/rsyslog.conf"
     VIRTIO_PORT = "/dev/virtio-ports/org.fedoraproject.anaconda.log.0"
-- 
1.9.3



More information about the anaconda-patches mailing list