RegisterHooks wraps a Core and runs a collection of user-defined callback hooks each time a message is logged. Execution of the callbacks is blocking. This offers users an easy way to register simple callbacks (e.g., metrics collection) without implementing the full Core interface.
(core Core, hooks ...func(Entry) error)
| 38 | // This offers users an easy way to register simple callbacks (e.g., metrics |
| 39 | // collection) without implementing the full Core interface. |
| 40 | func RegisterHooks(core Core, hooks ...func(Entry) error) Core { |
| 41 | funcs := append([]func(Entry) error{}, hooks...) |
| 42 | return &hooked{ |
| 43 | Core: core, |
| 44 | funcs: funcs, |
| 45 | } |
| 46 | } |
| 47 | |
| 48 | func (h *hooked) Level() Level { |
| 49 | return LevelOf(h.Core) |