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

Function TestReplaceHooks

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

Source from the content-addressed store, hash-verified

633}
634
635func TestReplaceHooks(t *testing.T) {
636 old, cur := &TestHook{}, &TestHook{}
637
638 logger := New()
639 logger.SetOutput(io.Discard)
640 logger.AddHook(old)
641
642 hooks := make(LevelHooks)
643 hooks.Add(cur)
644 replaced := logger.ReplaceHooks(hooks)
645
646 logger.Info("test")
647
648 assert.False(t, old.Fired)
649 assert.True(t, cur.Fired)
650
651 logger.ReplaceHooks(replaced)
652 logger.Info("test")
653 assert.True(t, old.Fired)
654}
655
656// Compile test
657func TestLogrusInterfaces(t *testing.T) {

Callers

nothing calls this directly

Calls 6

NewFunction · 0.85
SetOutputMethod · 0.80
AddHookMethod · 0.80
AddMethod · 0.80
ReplaceHooksMethod · 0.80
InfoMethod · 0.65

Tested by

no test coverage detected