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

Function ExampleObjects

example_test.go:375–389  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

373}
374
375func ExampleObjects() {
376 logger := zap.NewExample()
377 defer logger.Sync()
378
379 // Use the Objects field constructor when you have a list of objects,
380 // all of which implement zapcore.ObjectMarshaler.
381 logger.Debug("opening connections",
382 zap.Objects("addrs", []addr{
383 {IP: "123.45.67.89", Port: 4040},
384 {IP: "127.0.0.1", Port: 4041},
385 {IP: "192.168.0.1", Port: 4042},
386 }))
387 // Output:
388 // {"level":"debug","msg":"opening connections","addrs":[{"ip":"123.45.67.89","port":4040},{"ip":"127.0.0.1","port":4041},{"ip":"192.168.0.1","port":4042}]}
389}
390
391func ExampleDictObject() {
392 logger := zap.NewExample()

Callers

nothing calls this directly

Calls 4

NewExampleFunction · 0.92
ObjectsFunction · 0.92
SyncMethod · 0.65
DebugMethod · 0.45

Tested by

no test coverage detected