Skip to content

Commit

Permalink
Merge pull request #92 from GitMirar/fix-issue-87
Browse files Browse the repository at this point in the history
fix for issue #87
  • Loading branch information
Neo23x0 authored Nov 16, 2017
2 parents 1d97792 + d827217 commit c9d0f26
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion lib/lokilogger.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,10 +95,17 @@ def log(self, mes_type, message):
self.log_to_remotesys(message, mes_type)

def log_to_stdout(self, message, mes_type):
# check tty encoding
encoding = ""
if sys.stdout.encoding is not None:
encoding = sys.stdout.encoding
else:
# fallback on utf-8
encoding = "utf-8"

# Prepare Message
codecs.register(lambda message: codecs.lookup('utf-8') if message == 'cp65001' else None)
message = message.encode(sys.stdout.encoding, errors='replace')
message = message.encode(encoding, errors='replace')

if self.csv:
print ("{0},{1},{2},{3}".format(getSyslogTimestamp(),self.hostname,mes_type,message))
Expand Down

0 comments on commit c9d0f26

Please sign in to comment.