← Back to team overview

yahoo-eng-team team mailing list archive

[Bug 1563295] Re: Inconsistent behaviour when unicode args used for logging

 

Can be easily reproduced with:
from oslo_log import log as logging
LOG = logging.getLogger(__name__)
LOG.info("Oslo Logging %s", u'\u2622'.encode('utf8'))

The issue is related to implicit decoding of logging arguments due
_ensure_unicode for message:
https://github.com/openstack/oslo.log/blob/master/oslo_log/log.py#L129


** Changed in: oslo.log
       Status: New => Confirmed

** Also affects: nova
   Importance: Undecided
       Status: New

-- 
You received this bug notification because you are a member of Yahoo!
Engineering Team, which is subscribed to OpenStack Compute (nova).
https://bugs.launchpad.net/bugs/1563295

Title:
  Inconsistent behaviour when unicode args used for logging

Status in oslo.log:
  Confirmed

Bug description:
  When i used unicode args for log message, i got UnicodeDecodeError
  If replace using oslo_log to logging from std python library, logging works fine

  [1] Sample script, logging with oslo_log module http://paste.openstack.org/show/492234/
  [2] Sample script, logging with Python logging module  http://paste.openstack.org/show/492234/
  [3] Sample file with unicode data http://paste.openstack.org/show/492235/

  How to reproduce:

  1 Save [3] as 'text.txt'
  2 Run [1]

  Expected result:

  File log.txt contains
  "жлдоыфв
  фыжваофждыов"

  Actual result:

  Exception "UnicodeDecodeError: 'ascii' codec can't decode byte 0xd0 in position 0: ordinal not in range(128)
  Logged from file oslo_test.py, line 9"

  $ pip freeze|grep oslo.log

  oslo.log==3.2.0

To manage notifications about this bug go to:
https://bugs.launchpad.net/oslo.log/+bug/1563295/+subscriptions