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

Function TestDisabledLevel

log_test.go:937–961  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

935}
936
937func TestDisabledLevel(t *testing.T) {
938 lw := &levelWriter{
939 ops: []struct {
940 l Level
941 p string
942 }{},
943 }
944
945 // Allow extra-verbose logs.
946 SetGlobalLevel(TraceLevel - 1)
947 log := New(lw).Level(Disabled)
948 log.Error().Msg("0") // will not log
949 log.Log().Msg("nolevel-1") // will not log
950 log.WithLevel(ErrorLevel).Msg("3") // will not log
951 log.WithLevel(NoLevel).Msg("nolevel-2") // will not log
952 log.WithLevel(Disabled).Msg("Disabled") // will not log
953
954 want := []struct {
955 l Level
956 p string
957 }{}
958 if got := lw.ops; !reflect.DeepEqual(got, want) {
959 t.Errorf("invalid ops:\ngot:\n%v\nwant:\n%v", got, want)
960 }
961}
962
963func TestPanicLevel(t *testing.T) {
964 lw := &levelWriter{

Callers

nothing calls this directly

Calls 7

SetGlobalLevelFunction · 0.85
NewFunction · 0.85
LevelMethod · 0.80
MsgMethod · 0.80
WithLevelMethod · 0.80
LogMethod · 0.65
ErrorMethod · 0.45

Tested by

no test coverage detected