There are problems in oslo library related to encoding:
1. If in python 2.7 I try to log string like:
logging.warning('test message with unicode %s', u'☢ ☯ ☭ ∑ ∞ ♀ ♂ ♥'.encode('utf8'))
it's ok, but with olso:
from oslo_log import log as logging LOG = logging.getLogger(__name__) LOG.warning('test message with unicode %s', u'☢ ☯ ☭ ∑ ∞ ♀ ♂ ♥'.encode('utf8'))
UnicodeDecodeError: 'ascii' codec can't decode byte 0xe2 in position 0: ordinal not in range(128)
On https://github.com/openstack/oslo.log/blob/master/oslo_log/log.py#L129 ensure_unicode is only for message but not for args.
2. If I replace previous code to:
LOG.warning(u'test message with unicode ☢ ☯ ☭ ∑ ∞ ♀ ♂ ♥'.encode('utf8'))
with syslog, I've got error like: ERROR oslo_messaging.rpc.dispatcher File "/usr/lib/python2.7/dist-packages/oslo_log/handlers.py", line 57, in emit ERROR oslo_messaging.rpc.dispatcher self.format(record)) ERROR oslo_messaging.rpc.dispatcher TypeError: [priority,] message string
May be it's related to https://bugs.launchpad.net/oslo.log/+bug/1483842.
I'll make workraround to remove non ascii characters in log.
There are problems in oslo library related to encoding:
1. If in python 2.7 I try to log string like:
logging. warning( 'test message with unicode %s', u'☢ ☯ ☭ ∑ ∞ ♀ ♂ ♥'.encode('utf8'))
it's ok, but with olso:
from oslo_log import log as logging getLogger( __name_ _)
LOG = logging.
LOG.warning('test message with unicode %s', u'☢ ☯ ☭ ∑ ∞ ♀ ♂ ♥'.encode('utf8'))
UnicodeDecodeError: 'ascii' codec can't decode byte 0xe2 in position
0: ordinal not in range(128)
On https:/ /github. com/openstack/ oslo.log/ blob/master/ oslo_log/ log.py# L129
ensure_unicode is only for message but not for args.
2. If I replace previous code to:
LOG.warning(u'test message with unicode ☢ ☯ ☭ ∑ ∞ ♀ ♂ ♥'.encode('utf8'))
with syslog, I've got error like: rpc.dispatcher File "/usr/lib/ python2. 7/dist- packages/ oslo_log/ handlers. py", line 57, in emit rpc.dispatcher self.format( record) ) rpc.dispatcher TypeError: [priority,] message string
ERROR oslo_messaging.
ERROR oslo_messaging.
ERROR oslo_messaging.
May be it's related to https:/ /bugs.launchpad .net/oslo. log/+bug/ 1483842.
I'll make workraround to remove non ascii characters in log.