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

Function New

log.go:246–255  ·  log.go::New

New creates a root logger with given output writer. If the output writer implements the LevelWriter interface, the WriteLevel method will be called instead of the Write one. Each logging operation makes a single call to the Writer's Write method. There is no guarantee on access serialization to the

(w io.Writer)

Source from the content-addressed store, hash-verified

244// guarantee on access serialization to the Writer. If your Writer is not thread safe,
245// you may consider using sync wrapper.
246func New(w io.Writer) Logger {
247 if w == nil {
248 w = io.Discard
249 }
250 lw, ok := w.(LevelWriter)
251 if !ok {
252 lw = LevelWriterAdapter{w}
253 }
254 return Logger{w: lw, level: TraceLevel}
255}
256
257// Nop returns a disabled logger for which all operation are no-op.
258func Nop() Logger {

Callers 15

ExampleNewFunction · 0.92
ExampleLogger_WithFunction · 0.92
ExampleLogger_LevelFunction · 0.92
ExampleLogger_SampleFunction · 0.92
ExampleLogger_HookFunction · 0.92
ExampleLogger_PrintFunction · 0.92
ExampleLogger_PrintfFunction · 0.92
ExampleLogger_PrintlnFunction · 0.92
ExampleLogger_TraceFunction · 0.92
ExampleLogger_DebugFunction · 0.92
ExampleLogger_InfoFunction · 0.92
ExampleLogger_WarnFunction · 0.92

Calls

no outgoing calls

Tested by 15

ExampleNewFunction · 0.74
ExampleLogger_WithFunction · 0.74
ExampleLogger_LevelFunction · 0.74
ExampleLogger_SampleFunction · 0.74
ExampleLogger_HookFunction · 0.74
ExampleLogger_PrintFunction · 0.74
ExampleLogger_PrintfFunction · 0.74
ExampleLogger_PrintlnFunction · 0.74
ExampleLogger_TraceFunction · 0.74
ExampleLogger_DebugFunction · 0.74
ExampleLogger_InfoFunction · 0.74
ExampleLogger_WarnFunction · 0.74