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

Function ExampleLogger_Hook

binary_test.go:70–81  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

68}
69
70func ExampleLogger_Hook() {
71 var levelNameHook LevelNameHook1
72 var messageHook MessageHook = "The message"
73
74 dst := bytes.Buffer{}
75 log := New(&dst).Hook(levelNameHook).Hook(messageHook)
76
77 log.Info().Msg("hello world")
78
79 fmt.Println(decodeIfBinaryToString(dst.Bytes()))
80 // Output: {"level":"info","level_name":"info","the_message":"hello world","message":"hello world"}
81}
82
83func ExampleLogger_Print() {
84 dst := bytes.Buffer{}

Callers

nothing calls this directly

Calls 7

NewFunction · 0.85
HookMethod · 0.80
MsgMethod · 0.80
PrintlnMethod · 0.80
decodeIfBinaryToStringFunction · 0.70
InfoMethod · 0.65
BytesMethod · 0.45

Tested by

no test coverage detected