Fixes bug that prevents syslog returner from working under Python 2.6

Fixes #40688
This commit is contained in:
Jim Adson 2017-04-13 15:33:54 -06:00
parent 3cd9a50b22
commit e5a3a7d217

View File

@ -192,10 +192,14 @@ def returner(ret):
logoption = logoption | getattr(syslog, opt)
# Open syslog correctly based on options and tag
if 'tag' in _options:
syslog.openlog(ident=_options['tag'], logoption=logoption)
else:
syslog.openlog(logoption=logoption)
try:
if 'tag' in _options:
syslog.openlog(ident=_options['tag'], logoption=logoption)
else:
syslog.openlog(logoption=logoption)
except TypeError:
# Python 2.6 syslog.openlog does not accept keyword args
syslog.openlog(_options.get('tag', 'salt-minion'), logoption)
# Send log of given level and facility
syslog.syslog(facility | level, '{0}'.format(json.dumps(ret)))