MCPcopy
hub / github.com/rs/zerolog / With

Method With

log.go:279–290  ·  view source on GitHub ↗

With creates a child logger with the field added to its context.

()

Source from the content-addressed store, hash-verified

277
278// With creates a child logger with the field added to its context.
279func (l Logger) With() Context {
280 context := l.context
281 l.context = make([]byte, 0, 500)
282 if context != nil {
283 l.context = append(l.context, context...)
284 } else {
285 // This is needed for AppendKey to not check len of input
286 // thus making it inlinable
287 l.context = enc.AppendBeginMarker(l.context)
288 }
289 return Context{l}
290}
291
292// UpdateContext updates the internal logger's context.
293//

Callers 15

ExampleLogger_WithFunction · 0.80
ExampleLogger_WriteFunction · 0.80
ExampleContext_DictFunction · 0.80
ExampleContext_ArrayFunction · 0.80
ExampleContext_ObjectFunction · 0.80
ExampleContext_ObjectsFunction · 0.80
ExampleContext_ObjectsVFunction · 0.80
ExampleContext_InterfaceFunction · 0.80
ExampleContext_DurFunction · 0.80
ExampleContext_DursFunction · 0.80

Calls 1

AppendBeginMarkerMethod · 0.65

Tested by 15

ExampleLogger_WithFunction · 0.64
ExampleLogger_WriteFunction · 0.64
ExampleContext_DictFunction · 0.64
ExampleContext_ArrayFunction · 0.64
ExampleContext_ObjectFunction · 0.64
ExampleContext_ObjectsFunction · 0.64
ExampleContext_ObjectsVFunction · 0.64
ExampleContext_InterfaceFunction · 0.64
ExampleContext_DurFunction · 0.64
ExampleContext_DursFunction · 0.64