Remove str() from LOG.* and exceptions
gettextutils is expecting to receive unicode strings rather than basestrings. A basestring can cause an unhandled exception in the logging code. To help avoid such issues we should remove str() from LOG.* messages and exceptions. We have verified that the %s formatting code properly handle getting strings to unicode where necessary. Copied from https://review.openstack.org/#/c/77722 Change-Id: I082af5c9ae8bf9859382c2c387b10b48358e10b3 Related-Bug: #1286306
This commit is contained in:
parent
f676b335ce
commit
23edc1b4ce
|
@ -137,7 +137,7 @@ class ReplyWaiters(object):
|
||||||
LOG.warn('No calling threads waiting for msg_id : %(msg_id)s'
|
LOG.warn('No calling threads waiting for msg_id : %(msg_id)s'
|
||||||
', message : %(data)s', {'msg_id': msg_id,
|
', message : %(data)s', {'msg_id': msg_id,
|
||||||
'data': message_data})
|
'data': message_data})
|
||||||
LOG.warn('_queues: %s' % str(self._queues))
|
LOG.warn('_queues: %s' % self._queues)
|
||||||
else:
|
else:
|
||||||
queue.put(message_data)
|
queue.put(message_data)
|
||||||
|
|
||||||
|
|
|
@ -574,7 +574,7 @@ class Connection(object):
|
||||||
add it to our list of consumers
|
add it to our list of consumers
|
||||||
"""
|
"""
|
||||||
def _connect_error(exc):
|
def _connect_error(exc):
|
||||||
log_info = {'topic': topic, 'err_str': str(exc)}
|
log_info = {'topic': topic, 'err_str': exc}
|
||||||
LOG.error(_("Failed to declare consumer for topic '%(topic)s': "
|
LOG.error(_("Failed to declare consumer for topic '%(topic)s': "
|
||||||
"%(err_str)s") % log_info)
|
"%(err_str)s") % log_info)
|
||||||
|
|
||||||
|
@ -590,12 +590,11 @@ class Connection(object):
|
||||||
|
|
||||||
def _error_callback(exc):
|
def _error_callback(exc):
|
||||||
if isinstance(exc, qpid_exceptions.Empty):
|
if isinstance(exc, qpid_exceptions.Empty):
|
||||||
LOG.debug(_('Timed out waiting for RPC response: %s') %
|
LOG.debug(_('Timed out waiting for RPC response: %s') % exc)
|
||||||
str(exc))
|
|
||||||
raise rpc_common.Timeout()
|
raise rpc_common.Timeout()
|
||||||
else:
|
else:
|
||||||
LOG.exception(_('Failed to consume message from queue: %s') %
|
LOG.exception(_('Failed to consume message from queue: %s') %
|
||||||
str(exc))
|
exc)
|
||||||
|
|
||||||
def _consume():
|
def _consume():
|
||||||
nxt_receiver = self.session.next_receiver(timeout=timeout)
|
nxt_receiver = self.session.next_receiver(timeout=timeout)
|
||||||
|
@ -613,7 +612,7 @@ class Connection(object):
|
||||||
"""Send to a publisher based on the publisher class."""
|
"""Send to a publisher based on the publisher class."""
|
||||||
|
|
||||||
def _connect_error(exc):
|
def _connect_error(exc):
|
||||||
log_info = {'topic': topic, 'err_str': str(exc)}
|
log_info = {'topic': topic, 'err_str': exc}
|
||||||
LOG.exception(_("Failed to publish message to topic "
|
LOG.exception(_("Failed to publish message to topic "
|
||||||
"'%(topic)s': %(err_str)s") % log_info)
|
"'%(topic)s': %(err_str)s") % log_info)
|
||||||
|
|
||||||
|
|
|
@ -594,7 +594,7 @@ class Connection(object):
|
||||||
raise
|
raise
|
||||||
|
|
||||||
log_info = {}
|
log_info = {}
|
||||||
log_info['err_str'] = str(e)
|
log_info['err_str'] = e
|
||||||
log_info['max_retries'] = self.max_retries
|
log_info['max_retries'] = self.max_retries
|
||||||
log_info.update(params)
|
log_info.update(params)
|
||||||
|
|
||||||
|
@ -668,7 +668,7 @@ class Connection(object):
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def _connect_error(exc):
|
def _connect_error(exc):
|
||||||
log_info = {'topic': topic, 'err_str': str(exc)}
|
log_info = {'topic': topic, 'err_str': exc}
|
||||||
LOG.error(_("Failed to declare consumer for topic '%(topic)s': "
|
LOG.error(_("Failed to declare consumer for topic '%(topic)s': "
|
||||||
"%(err_str)s") % log_info)
|
"%(err_str)s") % log_info)
|
||||||
|
|
||||||
|
@ -685,12 +685,11 @@ class Connection(object):
|
||||||
|
|
||||||
def _error_callback(exc):
|
def _error_callback(exc):
|
||||||
if isinstance(exc, socket.timeout):
|
if isinstance(exc, socket.timeout):
|
||||||
LOG.debug(_('Timed out waiting for RPC response: %s') %
|
LOG.debug(_('Timed out waiting for RPC response: %s') % exc)
|
||||||
str(exc))
|
|
||||||
raise rpc_common.Timeout()
|
raise rpc_common.Timeout()
|
||||||
else:
|
else:
|
||||||
LOG.exception(_('Failed to consume message from queue: %s') %
|
LOG.exception(_('Failed to consume message from queue: %s') %
|
||||||
str(exc))
|
exc)
|
||||||
self.do_consume = True
|
self.do_consume = True
|
||||||
|
|
||||||
def _consume():
|
def _consume():
|
||||||
|
@ -712,7 +711,7 @@ class Connection(object):
|
||||||
"""Send to a publisher based on the publisher class."""
|
"""Send to a publisher based on the publisher class."""
|
||||||
|
|
||||||
def _error_callback(exc):
|
def _error_callback(exc):
|
||||||
log_info = {'topic': topic, 'err_str': str(exc)}
|
log_info = {'topic': topic, 'err_str': exc}
|
||||||
LOG.exception(_("Failed to publish message to topic "
|
LOG.exception(_("Failed to publish message to topic "
|
||||||
"'%(topic)s': %(err_str)s") % log_info)
|
"'%(topic)s': %(err_str)s") % log_info)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue