From b4d8d860f1fce42efd628195c429b887da884fa3 Mon Sep 17 00:00:00 2001 From: Ask Solem Date: Fri, 12 Jun 2015 12:53:54 -0700 Subject: [PATCH] ConsumerMixin: Connection error logs now include traceback. Closes #480 --- kombu/mixins.py | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/kombu/mixins.py b/kombu/mixins.py index 081ae580..4793e8fb 100644 --- a/kombu/mixins.py +++ b/kombu/mixins.py @@ -28,6 +28,14 @@ __all__ = ['ConsumerMixin'] logger = get_logger(__name__) debug, info, warn, error = logger.debug, logger.info, logger.warn, logger.error +W_CONN_LOST = """\ +Connection to broker lost, trying to re-establish connection...\ +""" + +W_CONN_ERROR = """\ +Broker connection error, trying again in %s seconds: %r.\ +""" + class ConsumerMixin(object): """Convenience mixin for implementing consumer programs. @@ -153,8 +161,7 @@ class ConsumerMixin(object): message.ack() def on_connection_error(self, exc, interval): - warn('Broker connection error: %r. ' - 'Trying again in %s seconds.', exc, interval) + warn(W_CONN_ERROR, interval, exc, exc_info=1) @contextmanager def extra_context(self, connection, channel): @@ -172,8 +179,7 @@ class ConsumerMixin(object): else: sleep(restart_limit.expected_time(_tokens)) except errors: - warn('Connection to broker lost. ' - 'Trying to re-establish the connection...') + warn(W_CONN_LOST, exc_info=1) @contextmanager def consumer_context(self, **kwargs):