Enhance error logging
- Prevent to fall into error logging recursion when it doesn't have request info (Print 'Unknown' when the request is still `None` - Print repr(e) rather than str(e)
This commit is contained in:
parent
6ecf2a6eb2
commit
b44e8167d7
|
@ -179,7 +179,8 @@ class HttpProtocol(asyncio.Protocol):
|
||||||
self.request.ip))
|
self.request.ip))
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
self.bail_out(
|
self.bail_out(
|
||||||
"Writing response failed, connection closed {}".format(e))
|
"Writing response failed, connection closed {}".format(
|
||||||
|
repr(e)))
|
||||||
finally:
|
finally:
|
||||||
if not keep_alive:
|
if not keep_alive:
|
||||||
self.transport.close()
|
self.transport.close()
|
||||||
|
@ -196,10 +197,10 @@ class HttpProtocol(asyncio.Protocol):
|
||||||
except RuntimeError:
|
except RuntimeError:
|
||||||
log.error(
|
log.error(
|
||||||
'Connection lost before error written @ {}'.format(
|
'Connection lost before error written @ {}'.format(
|
||||||
self.request.ip))
|
self.request.ip if self.request else 'Unknown'))
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
self.bail_out(
|
self.bail_out(
|
||||||
"Writing error failed, connection closed {}".format(e),
|
"Writing error failed, connection closed {}".format(repr(e)),
|
||||||
from_error=True)
|
from_error=True)
|
||||||
finally:
|
finally:
|
||||||
self.transport.close()
|
self.transport.close()
|
||||||
|
|
Loading…
Reference in New Issue
Block a user