-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add more information to default logs #121
Comments
I like the idea, as far as I understood you are actually proposing two improvements on the same feature:
I think fastify already provides us a nice way to gather all the request params so I think that this could be really easy to implement, i worry they might have sensitive data, however we already log the full path hence there'd be no issue in adding params (we might have to redact specific params in the future)
As far as I understood you wish that the user could provide custom properties to be added to the library logs, however the proposed snippet interface would be to let the user define a function that receives the full log generated and the reply giving the user a way to completely alter the library log and/or use the reply to actually send content to the client. I think this interface could be abused, I can think of two possible alternatives:
What do you think about these possibilities? I think they might respond to different use-cases and are not mutually exclusive, we could implement them both. |
For the two possible alternatives:
|
I agree on preferring not to dealing with the merge, however I don't like it too much to allow the user to alter the log entirely, the purpose of this library is to provide a standard, if the user can do whatever it wants then the library (partly) loses its purpose. As per the second alternative I didn't express myself properly: the user could provide on init the path to keys in the request/etc that it wishes to be logged, it's our job then to find them and include them in the log (in a position specified by the user). The user could also provide some static key/value pairs that could be injected in all the logs but I don't see if we have a use case for this kind of feature right now. |
For the key/value pairs to add in every log, it was my initial idea: decorate the request with an For the rewrite, I think about this use case for example. |
I create a PR to have something to think about, only for the request completed log (#125). |
I close the issue, since the implementation for the request completed log is released. Reopen it if necessary also in incoming request. |
The feature you are proposing
For the default log created by the library (incoming request and request completed), I'd like to add some custom values which help to identify the scope of the api request.
Could be interesting also adds the request path params in a specific object
The description of the bug or the rationale of your proposal
Logs are used to aggregate and analyze information through some specific tool to visualize the information. In this way, it should be possible to aggregate and use information in a more easy way without add additional (and possibly not very useful) logs.
A snippet of code for replicating the issue or showing the proposal usage if applicable
If it is exposed an api
/foo/:id
, and a request is performed as/foo/my-id
, the object of the log could be something like:In addition, it could be possible to add an additional fields through the request object.
In the handler, could be available a function to add some custom params to log:
or something similar
The text was updated successfully, but these errors were encountered: