MCPcopy
hub / github.com/uber-go/zap / RegisterHooks

Function RegisterHooks

zapcore/hook.go:40–46  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

38// This offers users an easy way to register simple callbacks (e.g., metrics
39// collection) without implementing the full Core interface.
40func 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
48func (h *hooked) Level() Level {
49 return LevelOf(h.Core)

Callers 2

HooksFunction · 0.92
TestHooksFunction · 0.85

Calls

no outgoing calls

Tested by 1

TestHooksFunction · 0.68