add try expcept block into non ascii data encoding
@@ -253,7 +253,10 @@ class MultilineWithDirectionFormatter(logging.Formatter):
output = out_lines[0]
empty_prefix = self._calculate_empty_prefix(msg_lines[0], out_lines[0])
for line in out_lines[1:]:
- output += "{}|{}".format(empty_prefix, line.encode("utf-8"))
+ try:
+ output += "{}|{}".format(empty_prefix, line)
+ except UnicodeEncodeError:
+ output += "{}|{}".format(empty_prefix, line.encode('utf-8'))
# TODO: line completion for connection decoded data comming in chunks
return output
