1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2024-09-14 20:13:21 +02:00

Merge pull request #2774 from sfromm/issue2773

Catch exception when logging to systemd journal fails
This commit is contained in:
Michael DeHaan 2013-04-24 18:52:44 -07:00
commit 4e2f8fe0bb

View file

@ -692,7 +692,12 @@ class AnsibleModule(object):
journal_args.append("MODULE=%s" % os.path.basename(__file__))
for arg in log_args:
journal_args.append(arg.upper() + "=" + str(log_args[arg]))
journal.sendv(*journal_args)
try:
journal.sendv(*journal_args)
except IOError, e:
# fall back to syslog since logging to journal failed
syslog.openlog(module, 0, syslog.LOG_USER)
syslog.syslog(syslog.LOG_NOTICE, msg)
else:
syslog.openlog(module, 0, syslog.LOG_USER)
syslog.syslog(syslog.LOG_NOTICE, msg)