Fix log handling of unicode output to syslog in modules

pull/5983/merge
James Cammarata 11 years ago
parent 4cd403247d
commit 254f87e7dd

@ -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…
Cancel
Save