[PATCH] Map our log levels to syslog log levels

Samantha N. Bueno sbueno+anaconda at redhat.com
Tue Jul 1 14:13:46 UTC 2014


On Mon, Jun 30, 2014 at 03:04:58PM -0700, Brian C. Lane wrote:
> 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.

Ack.

> ---
>  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
> 
> _______________________________________________
> anaconda-patches mailing list
> anaconda-patches at lists.fedorahosted.org
> https://lists.fedorahosted.org/mailman/listinfo/anaconda-patches


More information about the anaconda-patches mailing list