-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add Stringers field constructor for slices of Stringer-compatible obj…
…ects (#1155) Add a new Zap field constructor that encodes a slice of zero or more objects which implement fmt.Stringer interface into a Zap array. Usage: ```go // type Request struct{ ... } // func (a Request) String() string // // var requests []Request = ... // logger.Info("sending requests", zap.Stringers("requests", requests)) ``` This API uses a type parameter so that users don't have to build a `[]fmt.Stringer` out of a `[]Request`, and can pass the `[]Request` directly to the API. We may need a StringerValues constructor to mirror ObjectValues in the future. Credits: @zmanji, @abhinav for the suggestions
- Loading branch information
Showing
2 changed files
with
92 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters