Skip to content
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions elasticsearch/connection/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,10 @@ def log_request_success(self, method, full_url, path, body, status_code, respons
# body has already been serialized to utf-8, deserialize it for logging
# TODO: find a better way to avoid (de)encoding the body back and forth
if body:
body = body.decode('utf-8', 'ignore')
try:
body = body.decode('utf-8', 'ignore')
except AttributeError:
pass

logger.info(
'%s %s [status:%s request:%.3fs]', method, full_url,
Expand All @@ -100,7 +103,10 @@ def log_request_fail(self, method, full_url, path, body, duration, status_code=N
# body has already been serialized to utf-8, deserialize it for logging
# TODO: find a better way to avoid (de)encoding the body back and forth
if body:
body = body.decode('utf-8', 'ignore')
try:
body = body.decode('utf-8', 'ignore')
except AttributeError:
pass

logger.debug('> %s', body)

Expand Down