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

Function ExampleContext_MACAddr

binary_test.go:634–647  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

632 // Output: {"foo":"bar","v4":"192.168.0.100/24","v6":"2001:db8:85a3::8a2e:370:7300/64","message":"hello world"}
633}
634func ExampleContext_MACAddr() {
635 mac := net.HardwareAddr{0x12, 0x34, 0x56, 0x78, 0x90, 0xab}
636
637 dst := bytes.Buffer{}
638 log := New(&dst).With().
639 Str("foo", "bar").
640 MACAddr("mac", mac).
641 Logger()
642
643 log.Log().Msg("hello world")
644
645 fmt.Println(decodeIfBinaryToString(dst.Bytes()))
646 // Output: {"foo":"bar","mac":"12:34:56:78:90:ab","message":"hello world"}
647}

Callers

nothing calls this directly

Calls 10

NewFunction · 0.85
LoggerMethod · 0.80
WithMethod · 0.80
MsgMethod · 0.80
PrintlnMethod · 0.80
decodeIfBinaryToStringFunction · 0.70
LogMethod · 0.65
MACAddrMethod · 0.45
StrMethod · 0.45
BytesMethod · 0.45

Tested by

no test coverage detected