| 935 | } |
| 936 | |
| 937 | func 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 | |
| 963 | func TestPanicLevel(t *testing.T) { |
| 964 | lw := &levelWriter{ |