ObjectValues constructs a field with the given key, holding a list of the provided objects, where pointers to these objects can be marshaled by Zap. Note that pointers to these objects must implement zapcore.ObjectMarshaler. That is, if you're trying to marshal a []Request, the MarshalLogObject met
(key string, values []T)
| 172 | // var requests []*Request = ... |
| 173 | // logger.Info("sending requests", zap.Objects("requests", requests)) |
| 174 | func ObjectValues[T any, P ObjectMarshalerPtr[T]](key string, values []T) Field { |
| 175 | return Array(key, objectValues[T, P](values)) |
| 176 | } |
| 177 | |
| 178 | type objectValues[T any, P ObjectMarshalerPtr[T]] []T |
| 179 |