Logging fixes

This commit is contained in:
Honza Král
2013-11-03 22:39:03 +01:00
parent 9e68ea91ed
commit b8b9f67092
2 changed files with 9 additions and 1 deletions
+1 -1
View File
@@ -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. """
+8
View File
@@ -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):
"""