MCPcopy
hub / github.com/uber-go/zap / MarshalLogArray

Method MarshalLogArray

array.go:180–194  ·  view source on GitHub ↗
(arr zapcore.ArrayEncoder)

Source from the content-addressed store, hash-verified

178type objectValues[T any, P ObjectMarshalerPtr[T]] []T
179
180func (os objectValues[T, P]) MarshalLogArray(arr zapcore.ArrayEncoder) error {
181 for i := range os {
182 // It is necessary for us to explicitly reference the "P" type.
183 // We cannot simply pass "&os[i]" to AppendObject because its type
184 // is "*T", which the type system does not consider as
185 // implementing ObjectMarshaler.
186 // Only the type "P" satisfies ObjectMarshaler, which we have
187 // to convert "*T" to explicitly.
188 var p P = &os[i]
189 if err := arr.AppendObject(p); err != nil {
190 return err
191 }
192 }
193 return nil
194}
195
196// Strings constructs a field that carries a slice of strings.
197func Strings(key string, ss []string) Field {

Callers

nothing calls this directly

Calls 1

AppendObjectMethod · 0.65

Tested by

no test coverage detected