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

Function TestFieldsDisabled

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

Source from the content-addressed store, hash-verified

662}
663
664func TestFieldsDisabled(t *testing.T) {
665 out := &bytes.Buffer{}
666 log := New(out).Level(InfoLevel)
667 now := time.Now()
668 log.Debug().
669 Objects("obj", []LogObjectMarshaler{fixtureObj{"a", "z", 1}}).
670 ObjectsV("obj_v", fixtureObj{"A", "Z", 2}).
671 Str("string", "foo").
672 Strs("strs", []string{"foo"}).
673 StrsV("strs_v", "baz").
674 Stringer("stringer", net.IP{127, 0, 0, 1}).
675 Stringers("stringers", []fmt.Stringer{net.IP{127, 0, 0, 1}}).
676 StringersV("stringers_v", net.IPv6loopback).
677 Bytes("bytes", []byte("bar")).
678 Hex("hex", []byte{0x12, 0xef}).
679 AnErr("some_err", nil).
680 Err(errors.New("some error")).
681 Func(func(e *Event) { e.Str("func", "func_output") }).
682 Bool("bool", true).
683 Int("int", 1).
684 Int8("int8", 2).
685 Int16("int16", 3).
686 Int32("int32", 4).
687 Int64("int64", 5).
688 Uint("uint", 6).
689 Uint8("uint8", 7).
690 Uint16("uint16", 8).
691 Uint32("uint32", 9).
692 Uint64("uint64", 10).
693 Float32("float32", 11).
694 Float64("float64", 12).
695 Dur("dur", 1*time.Second).
696 Time("time", time.Time{}).
697 TimeDiff("diff", now, now.Add(-10*time.Second)).
698 IPAddr("ip", net.IP{127, 0, 0, 1}).
699 IPPrefix("ip", net.IPNet{IP: net.IP{127, 0, 0, 1}, Mask: net.CIDRMask(24, 32)}).
700 MACAddr("mac", net.HardwareAddr{0x00, 0x14, 0x22, 0x01, 0x23, 0x45}).
701 Ctx(context.Background()).
702 Any("any", struct{ A string }{"test"}).
703 Interface("interface", fixtureObj{"a", "z", 1}).
704 Err(errors.New("some error")).
705 Msg("")
706 if got, want := decodeIfBinaryToString(out.Bytes()), ""; got != want {
707 t.Errorf("invalid log output:\ngot: %v\nwant: %v", got, want)
708 }
709}
710
711func TestMsgf(t *testing.T) {
712 out := &bytes.Buffer{}

Callers

nothing calls this directly

Calls 15

NewFunction · 0.85
LevelMethod · 0.80
MsgMethod · 0.80
TimeDiffMethod · 0.80
FuncMethod · 0.80
decodeIfBinaryToStringFunction · 0.70
ErrMethod · 0.65
DebugMethod · 0.65
InterfaceMethod · 0.45
AnyMethod · 0.45
CtxMethod · 0.45
MACAddrMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…