Permalink
Browse files

Syslog really hates Unicode

  • Loading branch information...
1 parent 6adccc0 commit 5aa6e0ee969ea5ed776771841d84c449b0fc871e @samjsharpe samjsharpe committed Mar 6, 2013
Showing with 2 additions and 2 deletions.
  1. +2 −2 nagios_check_cache.py
View
4 nagios_check_cache.py
@@ -83,7 +83,7 @@ def logprintexit(exitcode,message):
message = step['result']['error_message']
# Write out the step description and the status
fh.write("%s: Step: [%s] %s%s\n" % (runtime,step['result']['status'].upper()[:4],step['keyword'],step['name']))
- syslog(LOG_NOTICE,"%s | %s%s | %s | %s%s" % (step['result']['status'].upper()[:4],feature['uri'].split('/')[1].split('.')[0],priority,scenario['name'],step['keyword'],step['name']))
+ syslog(LOG_NOTICE,"%s | %s%s | %s | %s%s" % (step['result']['status'].upper()[:4],feature['uri'].split('/')[1].split('.')[0],priority,scenario['name'],step['keyword'],step['name'].encode("ascii","ignore")))
# If we have any rows (e.g. perhaps lists of URLs to visit, write them too)
if 'rows' in step:
for row in step['rows']:
@@ -94,7 +94,7 @@ def logprintexit(exitcode,message):
# If we encountered a failure, write out the error
if message != "":
fh.write("%s: Error: %s\n" % (runtime,message.partition('\n')[0]))
- syslog(LOG_NOTICE,"%s | %s%s | %s | %s%s | Error - %s" % (step['result']['status'].upper()[:4],feature['uri'].split('/')[1].split('.')[0],priority,scenario['name'],step['keyword'],step['name'],message.partition('\n')[0]))
+ syslog(LOG_NOTICE,"%s | %s%s | %s | %s%s | Error - %s" % (step['result']['status'].upper()[:4],feature['uri'].split('/')[1].split('.')[0],priority,scenario['name'],step['keyword'],step['name'].encode("ascii","ignore"),message.partition('\n')[0]))
# A blank line to make our log pretty
fh.write("%s:\n" % runtime)
fh.close()

0 comments on commit 5aa6e0e

Please sign in to comment.