diff --git a/elasticsearch/connection/base.py b/elasticsearch/connection/base.py index 7841fd02..40c487e5 100644 --- a/elasticsearch/connection/base.py +++ b/elasticsearch/connection/base.py @@ -59,7 +59,7 @@ class Connection(object): tracer.info("curl -X%s 'http://localhost:9200%s' -d '%s'", method, path, _pretty_json(body) if body else '') if tracer.isEnabledFor(logging.DEBUG): - tracer.debug('# [%s] (%.3fs)\n#%s', status_code, duration, _pretty_json(response).replace('\n', '\n#') if response else '') + tracer.debug('#[%s] (%.3fs)\n#%s', status_code, duration, _pretty_json(response).replace('\n', '\n#') if response else '') def log_request_fail(self, method, full_url, duration, status_code=None, exception=None): """ Log an unsuccessful API call. """ diff --git a/elasticsearch/connection_pool.py b/elasticsearch/connection_pool.py index be359bfe..13d545e3 100644 --- a/elasticsearch/connection_pool.py +++ b/elasticsearch/connection_pool.py @@ -1,11 +1,14 @@ import time import random +import logging try: from Queue import PriorityQueue, Empty except ImportError: from queue import PriorityQueue, Empty +logger = logging.getLogger('elasticsearch') + class ConnectionSelector(object): """ Simple class used to select a connection from a list of currently live @@ -133,6 +136,10 @@ class ConnectionPool(object): self.dead_count[connection] = dead_count timeout = self.dead_timeout * 2 ** min(dead_count - 1, self.timeout_cutoff) self.dead.put((now + timeout, connection)) + logger.warning( + 'Connection %r has failed for %i times in a row, putting on %i second timeout.', + connection, dead_count, timeout + ) def mark_live(self, connection): """ @@ -175,6 +182,7 @@ class ConnectionPool(object): # either we were forced or the connection is elligible to be retried self.connections.append(connection) + logger.info('Resurrecting connection %r (force=%s).', connection, force) def get_connection(self): """