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

Method Add

hooks.go:18–22  ·  view source on GitHub ↗

Add a hook to an instance of logger. This is called with `log.Hooks.Add(new(MyHook))` where `MyHook` implements the `Hook` interface.

(hook Hook)

Source from the content-addressed store, hash-verified

16// Add a hook to an instance of logger. This is called with
17// `log.Hooks.Add(new(MyHook))` where `MyHook` implements the `Hook` interface.
18func (hooks LevelHooks) Add(hook Hook) {
19 for _, level := range hook.Levels() {
20 hooks[level] = append(hooks[level], hook)
21 }
22}
23
24// Fire all the hooks for the passed level. Used by `entry.log` to fire
25// appropriate hooks for a log entry.

Callers 15

TestHookFireOrderFunction · 0.95
TestEntryHooksPanicFunction · 0.80
Example_hookFunction · 0.80
TestHookFiresFunction · 0.80
TestHookCanModifyEntryFunction · 0.80
TestCanFireMultipleHooksFunction · 0.80
TestAddHookRaceFunction · 0.80

Calls 1

LevelsMethod · 0.65

Tested by 15

TestHookFireOrderFunction · 0.76
TestEntryHooksPanicFunction · 0.64
Example_hookFunction · 0.64
TestHookFiresFunction · 0.64
TestHookCanModifyEntryFunction · 0.64
TestCanFireMultipleHooksFunction · 0.64
TestAddHookRaceFunction · 0.64