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