one-line-logger
one-line-logger copied to clipboard
Include response time in "request completed" log
Prerequisites
- [X] I have written a descriptive issue title
- [X] I have searched existing issues to ensure the feature has not already been requested
🚀 Feature Proposal
Hi! I think it will be better if the completed request log also included the original response time. Maybe something like this 2017-02-14 20:51:48.000+0800 - info - completed in 0.14731597900390625 seconds - request completed
I've been trying to implement this simple feature by myself, but I am not sure how to write test for this response time? Any recommendations maybe, so that I can open PR for this issue.
Thanks
Motivation
No response
Example
No response
I've been trying to implement this simple feature by myself, but I am not sure how to write test for this response time? Any recommendations maybe, so that I can open PR for this issue.
You need to use some fake timers for it such as sinon
What about this format instead?
2017-02-14 20:51:48.000+0800 - info - request completed in 147 ms
@TommyDew42 Would this fit to the concept of this logger?
The initial idea (fastify/fastify#4027) was simple and just to provide a better looking log to developers. I guess it's alright to add the response time if users find it useful? @mcollina
The timing information is easily adjusted by the user:
- https://www.fastify.io/docs/latest/Reference/Server/#disablerequestlogging
- https://www.fastify.io/docs/latest/Reference/Reply/#getresponsetime
The standard response log has that info already
Closing due to inactivity and, as others have highlighted, this can already be set.