MCPcopy
hub / github.com/rs/zerolog / ExampleLogger_Hook

Function ExampleLogger_Hook

log/log_example_test.go:206–212  ·  view source on GitHub ↗

Example of using the Logger Hook function to add hooks

()

Source from the content-addressed store, hash-verified

204
205// Example of using the Logger Hook function to add hooks
206func ExampleLogger_Hook() {
207 setup()
208
209 hooked := log.Hook(captainHook)
210 hooked.Info().Msg("watch out!")
211 // Output: {"level":"info","time":1199811905,"key":null,"is_error":false,"msg_len":10,"message":"watch out!"}
212}
213
214// Example of using the WithLevel function to set the log level
215func ExampleWithLevel() {

Callers

nothing calls this directly

Calls 4

HookFunction · 0.92
setupFunction · 0.85
MsgMethod · 0.80
InfoMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…