Fixes #6655 catch unicode encoding errors before sending to syslog
This commit is contained in:
parent
7b8d1c0ffd
commit
3194fbd365
1 changed files with 8 additions and 2 deletions
|
@ -804,6 +804,12 @@ class AnsibleModule(object):
|
||||||
else:
|
else:
|
||||||
msg = 'Invoked'
|
msg = 'Invoked'
|
||||||
|
|
||||||
|
# 6655 - allow for accented characters
|
||||||
|
try:
|
||||||
|
msg = unicode(msg).encode('utf8')
|
||||||
|
except UnicodeDecodeError, e:
|
||||||
|
pass
|
||||||
|
|
||||||
if (has_journal):
|
if (has_journal):
|
||||||
journal_args = ["MESSAGE=%s %s" % (module, msg)]
|
journal_args = ["MESSAGE=%s %s" % (module, msg)]
|
||||||
journal_args.append("MODULE=%s" % os.path.basename(__file__))
|
journal_args.append("MODULE=%s" % os.path.basename(__file__))
|
||||||
|
@ -814,10 +820,10 @@ class AnsibleModule(object):
|
||||||
except IOError, e:
|
except IOError, e:
|
||||||
# fall back to syslog since logging to journal failed
|
# fall back to syslog since logging to journal failed
|
||||||
syslog.openlog(str(module), 0, syslog.LOG_USER)
|
syslog.openlog(str(module), 0, syslog.LOG_USER)
|
||||||
syslog.syslog(syslog.LOG_NOTICE, unicode(msg).encode('utf8'))
|
syslog.syslog(syslog.LOG_NOTICE, msg) #1
|
||||||
else:
|
else:
|
||||||
syslog.openlog(str(module), 0, syslog.LOG_USER)
|
syslog.openlog(str(module), 0, syslog.LOG_USER)
|
||||||
syslog.syslog(syslog.LOG_NOTICE, unicode(msg).encode('utf8'))
|
syslog.syslog(syslog.LOG_NOTICE, msg) #2
|
||||||
|
|
||||||
def _set_cwd(self):
|
def _set_cwd(self):
|
||||||
try:
|
try:
|
||||||
|
|
Loading…
Add table
Reference in a new issue