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

Function ExampleObject

example_test.go:188–202  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

186}
187
188func ExampleObject() {
189 logger := zap.NewExample()
190 defer logger.Sync()
191
192 req := &request{
193 URL: "/test",
194 Listen: addr{"127.0.0.1", 8080},
195 Remote: addr{"127.0.0.1", 31200},
196 }
197 logger.Info("new request, in nested object", zap.Object("req", req))
198 logger.Info("new request, inline", zap.Inline(req))
199 // Output:
200 // {"level":"info","msg":"new request, in nested object","req":{"url":"/test","ip":"127.0.0.1","port":8080,"remote":{"ip":"127.0.0.1","port":31200}}}
201 // {"level":"info","msg":"new request, inline","url":"/test","ip":"127.0.0.1","port":8080,"remote":{"ip":"127.0.0.1","port":31200}}
202}
203
204func ExampleNewStdLog() {
205 logger := zap.NewExample()

Callers

nothing calls this directly

Calls 5

NewExampleFunction · 0.92
ObjectFunction · 0.92
InlineFunction · 0.92
SyncMethod · 0.65
InfoMethod · 0.45

Tested by

no test coverage detected