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

Method WithLevel

log.go:419–442  ·  view source on GitHub ↗

WithLevel starts a new message with level. Unlike Fatal and Panic methods, WithLevel does not terminate the program or stop the ordinary flow of a goroutine when used with their respective levels. You must call Msg on the returned event in order to send the event.

(level Level)

Source from the content-addressed store, hash-verified

417//
418// You must call Msg on the returned event in order to send the event.
419func (l *Logger) WithLevel(level Level) *Event {
420 switch level {
421 case TraceLevel:
422 return l.Trace()
423 case DebugLevel:
424 return l.Debug()
425 case InfoLevel:
426 return l.Info()
427 case WarnLevel:
428 return l.Warn()
429 case ErrorLevel:
430 return l.Error()
431 case FatalLevel:
432 return l.newEvent(FatalLevel, nil)
433 case PanicLevel:
434 return l.newEvent(PanicLevel, nil)
435 case NoLevel:
436 return l.Log()
437 case Disabled:
438 return nil
439 default:
440 return l.newEvent(level, nil)
441 }
442}
443
444// Log starts a new message with no level. Setting GlobalLevel to Disabled
445// will still disable events produced by this method.

Callers 9

ExampleLogger_WithLevelFunction · 0.80
TestLevelFunction · 0.80
TestLevelWriterFunction · 0.80
TestDisabledLevelFunction · 0.80
TestPanicLevelFunction · 0.80
TestFatalLevelFunction · 0.80
ExampleLogger_WithLevelFunction · 0.80
HandleMethod · 0.80
WithLevelFunction · 0.80

Calls 7

TraceMethod · 0.95
DebugMethod · 0.95
InfoMethod · 0.95
WarnMethod · 0.95
ErrorMethod · 0.95
newEventMethod · 0.95
LogMethod · 0.95

Tested by 7

ExampleLogger_WithLevelFunction · 0.64
TestLevelFunction · 0.64
TestLevelWriterFunction · 0.64
TestDisabledLevelFunction · 0.64
TestPanicLevelFunction · 0.64
TestFatalLevelFunction · 0.64
ExampleLogger_WithLevelFunction · 0.64