From 680c3421e041a56bbdaa87fe4698beaada9c0580 Mon Sep 17 00:00:00 2001 From: Christian Heimes Date: Tue, 28 Nov 2017 14:35:48 +0100 Subject: [PATCH] Omit SysLogHandler when /dev/log does not exist slaptests use SysLogHandler() to write logs to syslog. Don't create a SysLogHandler when /dev/log does not exist. This fixes a bug when building and testing python-ldap in containers or restricted build environments. https://github.com/python-ldap/python-ldap/pull/28 See: https://github.com/python-ldap/python-ldap/issues/43 Signed-off-by: Christian Heimes --- Lib/slapdtest.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Lib/slapdtest.py b/Lib/slapdtest.py index 0bef1c1..182097a 100644 --- a/Lib/slapdtest.py +++ b/Lib/slapdtest.py @@ -59,7 +59,7 @@ def combined_logger( pass # for writing to syslog new_logger = logging.getLogger(log_name) - if sys_log_format: + if sys_log_format and os.path.exists('/dev/log'): my_syslog_formatter = logging.Formatter( fmt=' '.join((log_name, sys_log_format))) my_syslog_handler = logging.handlers.SysLogHandler(