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

Function NewLazyWith

zapcore/lazy_with.go:34–40  ·  view source on GitHub ↗

NewLazyWith wraps a Core with a "lazy" Core that will only encode fields if the logger is written to (or is further chained in a lon-lazy manner).

(core Core, fields []Field)

Source from the content-addressed store, hash-verified

32// NewLazyWith wraps a Core with a "lazy" Core that will only encode fields if
33// the logger is written to (or is further chained in a lon-lazy manner).
34func NewLazyWith(core Core, fields []Field) Core {
35 return &lazyWithCore{
36 core: nil, // core is allocated once `initOnce` is called.
37 originalCore: core,
38 fields: fields,
39 }
40}
41
42func (d *lazyWithCore) initOnce() {
43 d.Once.Do(func() {

Callers 3

WithLazyMethod · 0.92
withLazyCoreFunction · 0.92
TestLazyCoreRaceFunction · 0.92

Calls

no outgoing calls

Tested by 2

withLazyCoreFunction · 0.74
TestLazyCoreRaceFunction · 0.74