From 8dbfab5556f9c26ed9bcb24f8f0844ceb4ab49cc Mon Sep 17 00:00:00 2001 From: benoitc Date: Mon, 24 Jun 2013 09:39:43 +0200 Subject: [PATCH] fix syslog in 2.6 socktype is only supported in 2,7 and sup. fix #541 --- gunicorn/glogging.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/gunicorn/glogging.py b/gunicorn/glogging.py index 24a2f6ca..a3d54e70 100644 --- a/gunicorn/glogging.py +++ b/gunicorn/glogging.py @@ -363,8 +363,15 @@ class Logger(object): socktype, addr = parse_syslog_address(cfg.syslog_addr) # finally setup the syslog handler - h = logging.handlers.SysLogHandler(address=addr, facility=facility, - socktype=socktype) + if sys.version_info >= (2, 7): + h = logging.handlers.SysLogHandler(address=addr, + facility=facility, socktype=socktype) + else: + # socktype is only supported in 2.7 and sup + # fix issue #541 + h = logging.handlers.SysLogHandler(address=addr, + facility=facility) + h.setFormatter(fmt) h._gunicorn = True log.addHandler(h)