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)
| 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). |
| 34 | func 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 | |
| 42 | func (d *lazyWithCore) initOnce() { |
| 43 | d.Once.Do(func() { |
no outgoing calls