MCPcopy
hub / github.com/sirupsen/logrus / TestEntryWriter

Function TestEntryWriter

logrus_test.go:686–702  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

684}
685
686func TestEntryWriter(t *testing.T) {
687 cw := channelWriter(make(chan []byte, 1))
688 log := New()
689 log.Out = cw
690 log.Formatter = new(JSONFormatter)
691 _, err := log.WithField("foo", "bar").WriterLevel(WarnLevel).Write([]byte("hello\n"))
692 if err != nil {
693 t.Error("unexecpted error", err)
694 }
695
696 bs := <-cw
697 var fields Fields
698 err = json.Unmarshal(bs, &fields)
699 require.NoError(t, err)
700 assert.Equal(t, "bar", fields["foo"])
701 assert.Equal(t, "warning", fields["level"])
702}
703
704func TestLogLevelEnabled(t *testing.T) {
705 log := New()

Callers

nothing calls this directly

Calls 6

channelWriterTypeAlias · 0.85
NewFunction · 0.85
WithFieldMethod · 0.65
ErrorMethod · 0.65
WriteMethod · 0.45
WriterLevelMethod · 0.45

Tested by

no test coverage detected