🔧 log Connection lost only if debug

This commit is contained in:
Maks Skorokhod 2017-10-09 15:50:36 +03:00
parent 0189e4ed59
commit 7610c0fb2e
No known key found for this signature in database
GPG Key ID: 23233B8320707983

View File

@ -342,8 +342,10 @@ class HttpProtocol(asyncio.Protocol):
self.url, type(response))
self.write_error(ServerError('Invalid response type'))
except RuntimeError:
logger.error('Connection lost before response written @ %s',
self.request.ip)
if self._debug:
logger.error('Connection lost before response written @ %s',
self.request.ip)
keep_alive = False
except Exception as e:
self.bail_out(
"Writing response failed, connection closed {}".format(
@ -379,8 +381,10 @@ class HttpProtocol(asyncio.Protocol):
self.url, type(response))
self.write_error(ServerError('Invalid response type'))
except RuntimeError:
logger.error('Connection lost before response written @ %s',
self.request.ip)
if self._debug:
logger.error('Connection lost before response written @ %s',
self.request.ip)
keep_alive = False
except Exception as e:
self.bail_out(
"Writing response failed, connection closed {}".format(
@ -407,8 +411,9 @@ class HttpProtocol(asyncio.Protocol):
version = self.request.version if self.request else '1.1'
self.transport.write(response.output(version))
except RuntimeError:
logger.error('Connection lost before error written @ %s',
self.request.ip if self.request else 'Unknown')
if self._debug:
logger.error('Connection lost before error written @ %s',
self.request.ip if self.request else 'Unknown')
except Exception as e:
self.bail_out(
"Writing error failed, connection closed {}".format(