Improves logging
This patch change log string formatting approach, moves it inside logging method to avoid formatting if it is not needed for given log level Change-Id: Ice73f2fc893701544cadc75bafd6833de0ae5d51
This commit is contained in:
parent
339a6236b3
commit
f93e162912
oslo_messaging/_drivers
@ -168,7 +168,7 @@ class PikaDriver(base.BaseDriver):
|
||||
def on_exception(ex):
|
||||
if isinstance(ex, (pika_drv_exc.ConnectionException,
|
||||
exceptions.MessageDeliveryFailure)):
|
||||
LOG.warn(str(ex))
|
||||
LOG.warn("Problem during message sending. %s", ex)
|
||||
return True
|
||||
else:
|
||||
return False
|
||||
@ -229,15 +229,16 @@ class PikaDriver(base.BaseDriver):
|
||||
def on_exception(ex):
|
||||
if isinstance(ex, (pika_drv_exc.ExchangeNotFoundException,
|
||||
pika_drv_exc.RoutingException)):
|
||||
LOG.warn(str(ex))
|
||||
LOG.warn("Problem during sending notification. %", ex)
|
||||
try:
|
||||
self._declare_notification_queue_binding(target)
|
||||
except pika_drv_exc.ConnectionException as e:
|
||||
LOG.warn(str(e))
|
||||
LOG.warn("Problem during declaring notification queue "
|
||||
"binding. %", e)
|
||||
return True
|
||||
elif isinstance(ex, (pika_drv_exc.ConnectionException,
|
||||
pika_drv_exc.MessageRejectedException)):
|
||||
LOG.warn(str(ex))
|
||||
LOG.warn("Problem during sending notification. %", ex)
|
||||
return True
|
||||
else:
|
||||
return False
|
||||
|
@ -270,9 +270,9 @@ class PikaEngine(object):
|
||||
pika_next_connection_num, for_listening
|
||||
)
|
||||
except pika_pool.Connection.connectivity_errors as e:
|
||||
LOG.warn(str(e))
|
||||
LOG.warn("Can't establish connection to host. %s", e)
|
||||
except pika_drv_exc.HostConnectionNotAllowedException as e:
|
||||
LOG.warn(str(e))
|
||||
LOG.warn("Connection to host is not Allowed. %s", e)
|
||||
|
||||
connection_attempts -= 1
|
||||
pika_next_connection_num += 1
|
||||
|
@ -195,7 +195,10 @@ class RpcPikaIncomingMessage(PikaIncomingMessage, base.RpcIncomingMessage):
|
||||
|
||||
def on_exception(ex):
|
||||
if isinstance(ex, pika_drv_exc.ConnectionException):
|
||||
LOG.warn(str(ex))
|
||||
LOG.warn(
|
||||
"Connectivity related problem during reply sending. %s",
|
||||
ex
|
||||
)
|
||||
return True
|
||||
else:
|
||||
return False
|
||||
@ -216,15 +219,12 @@ class RpcPikaIncomingMessage(PikaIncomingMessage, base.RpcIncomingMessage):
|
||||
retrier=retrier
|
||||
)
|
||||
LOG.debug(
|
||||
"Message [id:'{}'] replied to '{}'.".format(
|
||||
self.msg_id, self.reply_q
|
||||
)
|
||||
"Message [id:'%s'] replied to '%s'.", self.msg_id, self.reply_q
|
||||
)
|
||||
except Exception:
|
||||
LOG.exception(
|
||||
"Message [id:'{}'] wasn't replied to : {}".format(
|
||||
self.msg_id, self.reply_q
|
||||
)
|
||||
"Message [id:'%s'] wasn't replied to : %s", self.msg_id,
|
||||
self.reply_q
|
||||
)
|
||||
|
||||
|
||||
@ -277,8 +277,8 @@ class RpcReplyPikaIncomingMessage(PikaIncomingMessage):
|
||||
res_exc = ex_type(module_name, class_name, message, trace)
|
||||
except ImportError as e:
|
||||
LOG.warn(
|
||||
"Can not deserialize remote exception [module:{}, "
|
||||
"class:{}]. {}".format(module_name, class_name, str(e))
|
||||
"Can not deserialize remote exception [module:%s, "
|
||||
"class:%s]. %s", module_name, class_name, e
|
||||
)
|
||||
|
||||
# if we have not processed failure yet, use RemoteError class
|
||||
@ -449,10 +449,9 @@ class PikaOutgoingMessage(object):
|
||||
encoding=self._content_encoding)
|
||||
|
||||
LOG.debug(
|
||||
"Sending message:[body:{}; properties: {}] to target: "
|
||||
"[exchange:{}; routing_key:{}]".format(
|
||||
body, msg_props, exchange, routing_key
|
||||
)
|
||||
"Sending message:[body:%s; properties: %s] to target: "
|
||||
"[exchange:%s; routing_key:%s]", body, msg_props, exchange,
|
||||
routing_key
|
||||
)
|
||||
|
||||
publish = (self._publish if retrier is None else
|
||||
|
Loading…
x
Reference in New Issue
Block a user