Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

use hostnames and ports in warnings #572

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 13 additions & 10 deletions tornado/iostream.py
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ def __init__(self, socket, io_loop=None, max_buffer_size=104857600,
self.max_buffer_size = max_buffer_size
self.read_chunk_size = read_chunk_size
self.error = None
self.address = (None, 0)
self._read_buffer = collections.deque()
self._write_buffer = collections.deque()
self._read_buffer_size = 0
Expand Down Expand Up @@ -123,6 +124,7 @@ def connect(self, address, callback=None):
"""
self._connecting = True
try:
self.address = address
self.socket.connect(address)
except socket.error, e:
# In non-blocking mode we expect connect() to raise an
Expand All @@ -133,7 +135,8 @@ def connect(self, address, callback=None):
# localhost, so handle them the same way as an error
# reported later in _handle_connect.
if e.args[0] not in (errno.EINPROGRESS, errno.EWOULDBLOCK):
logging.warning("Connect error on fd %d: %s",
logging.warning("Connect error to %s:%d (fd %d): %s",
self.address[0], self.address[1],
self.socket.fileno(), e)
self.close()
return
Expand Down Expand Up @@ -421,7 +424,8 @@ def _read_to_buffer(self):
chunk = self._read_from_socket()
except socket.error, e:
# ssl.SSLError is a subclass of socket.error
logging.warning("Read error on %d: %s",
logging.warning("Read error to %s:%d (fd %d): %s",
self.address[0], self.address[1],
self.socket.fileno(), e)
self.close()
raise
Expand Down Expand Up @@ -503,7 +507,8 @@ def _handle_connect(self):
# an error state before the socket becomes writable, so
# in that case a connection failure would be handled by the
# error path in _handle_events instead of here.
logging.warning("Connect error on fd %d: %s",
logging.warning("Connect error to %s:%d (fd %d): %s",
self.address[0], self.address[1],
self.socket.fileno(), errno.errorcode[err])
self.close()
return
Expand Down Expand Up @@ -543,7 +548,8 @@ def _handle_write(self):
self._write_buffer_frozen = True
break
else:
logging.warning("Write error on %d: %s",
logging.warning("Write error to %s:%d (fd %d): %s",
self.address[0], self.address[1],
self.socket.fileno(), e)
self.close()
return
Expand Down Expand Up @@ -650,12 +656,9 @@ def _do_ssl_handshake(self):
ssl.SSL_ERROR_ZERO_RETURN):
return self.close()
elif err.args[0] == ssl.SSL_ERROR_SSL:
try:
peer = self.socket.getpeername()
except:
peer = '(not connected)'
logging.warning("SSL Error on %d %s: %s",
self.socket.fileno(), peer, err)
logging.warning("SSL Error to %s:%d (fd %d): %s",
self.address[0], self.address[1],
self.socket.fileno(), err)
return self.close()
raise
except socket.error, err:
Expand Down
6 changes: 4 additions & 2 deletions tornado/web.py
Original file line number Diff line number Diff line change
Expand Up @@ -1449,8 +1449,10 @@ def log_request(self, handler):
else:
log_method = logging.error
request_time = 1000.0 * handler.request.request_time()
log_method("%d %s %.2fms", handler.get_status(),
handler._request_summary(), request_time)
error_msg = "%d %s" % (handler.get_status(),
handler._request_summary())
error_msg = error_msg.replace('%', '%%')
log_method(error_msg + " %.2fms", request_time)


class HTTPError(Exception):
Expand Down