Skip to content

Commit

Permalink
Syslog really hates Unicode
Browse files Browse the repository at this point in the history
  • Loading branch information
Sam J Sharpe committed Mar 6, 2013
1 parent 6adccc0 commit 5aa6e0e
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions nagios_check_cache.py
Expand Up @@ -83,7 +83,7 @@ def logprintexit(exitcode,message):
message = step['result']['error_message'] message = step['result']['error_message']
# Write out the step description and the status # 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'])) 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 we have any rows (e.g. perhaps lists of URLs to visit, write them too)
if 'rows' in step: if 'rows' in step:
for row in step['rows']: for row in step['rows']:
Expand All @@ -94,7 +94,7 @@ def logprintexit(exitcode,message):
# If we encountered a failure, write out the error # If we encountered a failure, write out the error
if message != "": if message != "":
fh.write("%s: Error: %s\n" % (runtime,message.partition('\n')[0])) 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 # A blank line to make our log pretty
fh.write("%s:\n" % runtime) fh.write("%s:\n" % runtime)
fh.close() fh.close()
Expand Down

0 comments on commit 5aa6e0e

Please sign in to comment.