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

Function Hooks

options.go:55–59  ·  view source on GitHub ↗

Hooks registers functions which will be called each time the Logger writes out an Entry. Repeated use of Hooks is additive. Hooks are useful for simple side effects, like capturing metrics for the number of emitted logs. More complex side effects, including anything that requires access to the Entr

(hooks ...func(zapcore.Entry) error)

Source from the content-addressed store, hash-verified

53// requires access to the Entry's structured fields, should be implemented as
54// a zapcore.Core instead. See zapcore.RegisterHooks for details.
55func Hooks(hooks ...func(zapcore.Entry) error) Option {
56 return optionFunc(func(log *Logger) {
57 log.core = zapcore.RegisterHooks(log.core, hooks...)
58 })
59}
60
61// Fields adds fields to the Logger.
62func Fields(fs ...Field) Option {

Callers 2

TestConfigFunction · 0.85
TestLoggerHooksFunction · 0.85

Calls 2

RegisterHooksFunction · 0.92
optionFuncFuncType · 0.70

Tested by 2

TestConfigFunction · 0.68
TestLoggerHooksFunction · 0.68