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