ConsumerMixin: Connection error logs now include traceback. Closes #480

This commit is contained in:
Ask Solem 2015-06-12 12:53:54 -07:00
parent b6c3f99f66
commit b4d8d860f1
1 changed files with 10 additions and 4 deletions

View File

@ -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):