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

Function ExampleObjectValues

example_test.go:436–458  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

434}
435
436func ExampleObjectValues() {
437 logger := zap.NewExample()
438 defer logger.Sync()
439
440 // Use the ObjectValues field constructor when you have a list of
441 // objects that do not implement zapcore.ObjectMarshaler directly,
442 // but on their pointer receivers.
443 logger.Debug("starting tunnels",
444 zap.ObjectValues("addrs", []request{
445 {
446 URL: "/foo",
447 Listen: addr{"127.0.0.1", 8080},
448 Remote: addr{"123.45.67.89", 4040},
449 },
450 {
451 URL: "/bar",
452 Listen: addr{"127.0.0.1", 8080},
453 Remote: addr{"127.0.0.1", 31200},
454 },
455 }))
456 // Output:
457 // {"level":"debug","msg":"starting tunnels","addrs":[{"url":"/foo","ip":"127.0.0.1","port":8080,"remote":{"ip":"123.45.67.89","port":4040}},{"url":"/bar","ip":"127.0.0.1","port":8080,"remote":{"ip":"127.0.0.1","port":31200}}]}
458}

Callers

nothing calls this directly

Calls 4

NewExampleFunction · 0.92
ObjectValuesFunction · 0.92
SyncMethod · 0.65
DebugMethod · 0.45

Tested by

no test coverage detected