express-pino-logger
express-pino-logger copied to clipboard
log not output on timeout
I was trying to move from morgan to express-pino-logger but noticed that a log is not output when there's a timeout. morgan will output it with a status code of - but express-pino-logger doesn't output anything. Is there a setting to enable that output?
Have you got a snippet to reproduce the problem? Would you like to send a PR to fix this?
The issue is that the close event isn't being handled: https://nodejs.org/api/http.html#http_event_close_1
I feel like that should have a different msg than request completed, like connection closed. To my knowledge, there's not a way to distinguish that like how err and statusCode are checked for the error event handling. So does it need to be it's own function?
Also, in my quick testing by adding the event, it incorrectly logs statusCode as 200 when the connection is closed.
What appears to be happening with statusCode is that express is setting the res.statusCode to 200 and then that's being output, so that's probably more argument for the handler of the close event to be it's own function.