remove unnecessary str method when log messages
In Python 2 environment, if we use str(object) in log message, it will raise UnicodeError. And since we use string format in log messages, the explict str is a bit redundant too. See discussion in dev mailing list: http://lists.openstack.org/pipermail/openstack-dev/2014-June/038857.html See oslo.i18n source code: https://github.com/openstack/oslo.i18n/blob/1.1.0/oslo/i18n/_message.py#L159 Change-Id: Ie9d086a49d56634496a8efbe37ea04f6812e561c Closes-Bug: #1406728
This commit is contained in:
parent
e5ad0bac86
commit
8e01978eb2
@ -72,7 +72,7 @@ def check_keystone(service_type=None):
|
||||
keystone = _get_keystone()
|
||||
if isinstance(keystone, Exception):
|
||||
LOG.error(_('Skip due to keystone error %s'),
|
||||
str(keystone) if keystone else '')
|
||||
keystone if keystone else '')
|
||||
return iter([])
|
||||
elif service_type:
|
||||
endpoints = keystone.service_catalog.get_endpoints(
|
||||
|
@ -99,10 +99,10 @@ class CollectorService(os_service.Service):
|
||||
try:
|
||||
sample = msgpack.loads(data, encoding='utf-8')
|
||||
except Exception:
|
||||
LOG.warn(_("UDP: Cannot decode data sent by %s"), str(source))
|
||||
LOG.warn(_("UDP: Cannot decode data sent by %s"), source)
|
||||
else:
|
||||
try:
|
||||
LOG.debug(_("UDP: Storing %s"), str(sample))
|
||||
LOG.debug(_("UDP: Storing %s"), sample)
|
||||
self.dispatcher_manager.map_method('record_metering_data',
|
||||
sample)
|
||||
except Exception:
|
||||
|
@ -93,7 +93,7 @@ class ArithmeticTransformer(transformer.TransformerBase):
|
||||
)
|
||||
except Exception as e:
|
||||
LOG.warn(_('Unable to evaluate expression %(expr)s: %(exc)s'),
|
||||
{'expr': self.expr, 'exc': str(e)})
|
||||
{'expr': self.expr, 'exc': e})
|
||||
|
||||
def handle_sample(self, context, _sample):
|
||||
self._update_cache(_sample)
|
||||
|
Loading…
x
Reference in New Issue
Block a user