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

Method Output

log.go:263–276  ·  view source on GitHub ↗

Output duplicates the current logger and sets w as its output.

(w io.Writer)

Source from the content-addressed store, hash-verified

261
262// Output duplicates the current logger and sets w as its output.
263func (l Logger) Output(w io.Writer) Logger {
264 l2 := New(w)
265 l2.level = l.level
266 l2.sampler = l.sampler
267 l2.stack = l.stack
268 if len(l.hooks) > 0 {
269 l2.hooks = append(l2.hooks, l.hooks...)
270 }
271 if l.context != nil {
272 l2.context = make([]byte, len(l.context), cap(l.context))
273 copy(l2.context, l.context)
274 }
275 return l2
276}
277
278// With creates a child logger with the field added to its context.
279func (l Logger) With() Context {

Callers 5

TestOutputWithTimestampFunction · 0.80
TestOutputWithContextFunction · 0.80
TestHookFunction · 0.80
OutputFunction · 0.80

Calls 1

NewFunction · 0.85

Tested by 4

TestOutputWithTimestampFunction · 0.64
TestOutputWithContextFunction · 0.64
TestHookFunction · 0.64