Comment 6 for bug 1348244

Revision history for this message
James Carey (jecarey) wrote :

Before the change to no longer translate debug logs all messages were being converted to unicode by the _() implementation. Now the messages for debug logs are not translated by _() but, when oslo logging is used (log.py) the intention was that as part of the process() method on the ContextAdapter class (which is a LoggerAdapter returned from oslo's getLogger method) it would ensure that the log messages were unicode. In particular the check is:

        if not isinstance(msg, six.string_types):
            msg = six.text_type(msg)

Unfortunately the isinstance() is checking if it is an instance of six.string_types (i.e. checking if it is a str in PY3 or a basestring in PY2). This means that the cast to six.text_type (unicode) is only happening when the message does not need it. Instead the check should be if it is an instance of six.text_type so that when it isn't, the cast is done.:

        if not isinstance(msg, six.text_type):
            msg = six.text_type(msg)