Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
LogEntrySetFields: Use the varargs syntax to supply the additional lo…
…g arguments correctly Without the change in this changeset, running `go test` fails with: ``` ./httplog.go:361:37: slog.Logger.With arg "attrs" should be a string or a slog.Attr (possible missing key or value) FAIL ``` This is due to the fact that the array of `slog.Attr`s was supplied as a single arg (i.e. a single slice of attributes) to `*entry.Logger.With`, instead of a variable number of arguments. Example: ```go fields := map[string]any{ "remote": "example.com", "action": "update", } httplog.LogEntrySetFields(ctx, fields) ``` Without this change, the updated example that uses LogEntrySetFields creates the following log entry: ``` user: "user1" !BADKEY: [remote=example.com action=update] ``` With the change the log line for the updated example is: ``` user: "user1" remote: "example.com" action: "update" ```
- Loading branch information