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

Function TestFieldValueError

logger_test.go:13–29  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

11)
12
13func TestFieldValueError(t *testing.T) {
14 buf := &bytes.Buffer{}
15 l := &Logger{
16 Out: buf,
17 Formatter: new(JSONFormatter),
18 Hooks: make(LevelHooks),
19 Level: DebugLevel,
20 }
21 l.WithField("func", func() {}).Info("test")
22 fmt.Println(buf.String())
23 var data map[string]interface{}
24 if err := json.Unmarshal(buf.Bytes(), &data); err != nil {
25 t.Error("unexpected error", err)
26 }
27 _, ok := data[FieldKeyLogrusError]
28 require.True(t, ok, `cannot found expected "logrus_error" field: %v`, data)
29}
30
31func TestNoFieldValueError(t *testing.T) {
32 buf := &bytes.Buffer{}

Callers

nothing calls this directly

Calls 6

WithFieldMethod · 0.95
BytesMethod · 0.80
InfoMethod · 0.65
PrintlnMethod · 0.65
ErrorMethod · 0.65
StringMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…