Fixes unicode logging decoding issue
Logging fails with an exception when unicode conversion of the message cannot be performed. This includes also Exception objects, where the exception message has an unknown encoding. The calling code should be responsible for handling the unicode encoding, but nevertheless, the logging module should handle this scenario and not raise an exception. Closes-Bug: #1393870 Change-Id: Ied46e4a8715d11a3cf59d651004e17f6fe4c760b
This commit is contained in:
parent
8b8a34731d
commit
5344904f27
@ -307,7 +307,11 @@ class ContextAdapter(BaseLoggerAdapter):
|
||||
# before it can get to the python logging and
|
||||
# possibly cause string encoding trouble
|
||||
if not isinstance(msg, six.text_type):
|
||||
msg = six.text_type(msg)
|
||||
try:
|
||||
msg = six.text_type(msg)
|
||||
except UnicodeDecodeError:
|
||||
# Unknown encoding. Let the Python logging module handle it
|
||||
pass
|
||||
|
||||
if 'extra' not in kwargs:
|
||||
kwargs['extra'] = {}
|
||||
|
Loading…
Reference in New Issue
Block a user