You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Auto merge of #2234 - pietroalbini:log-publish-crate, r=jtgeibel
Include crate name and version in the publish API's log entries
This PR includes the crate name and version in the log entries of the publish API, to fix#2228 and to aid debugging issues in production. This is done in three steps.
First, the log entry generation code was refactored to easily allow adding new fields to it. Now, instead of hardcoding the list of fields in a `format!` macro, there is a builder with methods to add individual fields.
~~Then, a way to attach custom log fields to a response was added. This is implemented by setting HTTP headers in the response starting with `X-CratesIo-Log-Metadata-`, and by changing the middleware responsible for request logging to strip those headers and add their content to the log line instead.~~
Then, a way to attach custom log fields to a response was added. This is implemented as a "request extension", with a convenience method in the `ResponseExt` trait to add the custom log fields to all responses generated by that request.
Finally, this new feature was used to attach the crate name and version to the publish API's log entries.
r? @sgrif
0 commit comments