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

Function TestLogrusInterfaces

logrus_test.go:657–674  ·  view source on GitHub ↗

Compile test

(t *testing.T)

Source from the content-addressed store, hash-verified

655
656// Compile test
657func TestLogrusInterfaces(t *testing.T) {
658 var buffer bytes.Buffer
659 // This verifies FieldLogger and Ext1FieldLogger work as designed.
660 // Please don't use them. Use Logger and Entry directly.
661 fn := func(xl Ext1FieldLogger) {
662 var l FieldLogger = xl
663 b := l.WithField("key", "value")
664 b.Debug("Test")
665 }
666 // test logger
667 logger := New()
668 logger.Out = &buffer
669 fn(logger)
670
671 // test Entry
672 e := logger.WithField("another", "value")
673 fn(e)
674}
675
676// Implements io.Writer using channels for synchronization, so we can wait on
677// the Entry.Writer goroutine to write in a non-racey way. This does assume that

Callers

nothing calls this directly

Calls 3

WithFieldMethod · 0.95
NewFunction · 0.85
DebugMethod · 0.65

Tested by

no test coverage detected