mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
Fix log handling of unicode output to syslog in modules
This commit is contained in:
parent
4cd403247d
commit
254f87e7dd
1 changed files with 6 additions and 3 deletions
|
@ -777,7 +777,10 @@ class AnsibleModule(object):
|
||||||
module = 'ansible-%s' % os.path.basename(__file__)
|
module = 'ansible-%s' % os.path.basename(__file__)
|
||||||
msg = ''
|
msg = ''
|
||||||
for arg in log_args:
|
for arg in log_args:
|
||||||
msg = msg + arg + '=' + str(log_args[arg]) + ' '
|
if isinstance(log_args[arg], unicode):
|
||||||
|
msg = msg + arg + '=' + log_args[arg] + ' '
|
||||||
|
else:
|
||||||
|
msg = msg + arg + '=' + str(log_args[arg]) + ' '
|
||||||
if msg:
|
if msg:
|
||||||
msg = 'Invoked with %s' % msg
|
msg = 'Invoked with %s' % msg
|
||||||
else:
|
else:
|
||||||
|
@ -793,10 +796,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, msg)
|
syslog.syslog(syslog.LOG_NOTICE, msg.encode('utf8'))
|
||||||
else:
|
else:
|
||||||
syslog.openlog(str(module), 0, syslog.LOG_USER)
|
syslog.openlog(str(module), 0, syslog.LOG_USER)
|
||||||
syslog.syslog(syslog.LOG_NOTICE, msg)
|
syslog.syslog(syslog.LOG_NOTICE, msg.encode('utf8'))
|
||||||
|
|
||||||
def get_bin_path(self, arg, required=False, opt_dirs=[]):
|
def get_bin_path(self, arg, required=False, opt_dirs=[]):
|
||||||
'''
|
'''
|
||||||
|
|
Loading…
Reference in a new issue