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

Function TestConsoleLogger

console_test.go:89–102  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

87}
88
89func TestConsoleLogger(t *testing.T) {
90 t.Run("Numbers", func(t *testing.T) {
91 buf := &bytes.Buffer{}
92 log := zerolog.New(zerolog.ConsoleWriter{Out: buf, NoColor: true})
93 log.Info().
94 Float64("float", 1.23).
95 Uint64("small", 123).
96 Uint64("big", 1152921504606846976).
97 Msg("msg")
98 if got, want := strings.TrimSpace(buf.String()), "<nil> INF msg big=1152921504606846976 float=1.23 small=123"; got != want {
99 t.Errorf("\ngot:\n%s\nwant:\n%s", got, want)
100 }
101 })
102}
103
104func TestConsoleWriter(t *testing.T) {
105 t.Run("Default field formatter", func(t *testing.T) {

Callers

nothing calls this directly

Calls 7

NewFunction · 0.92
MsgMethod · 0.80
RunMethod · 0.65
InfoMethod · 0.65
Uint64Method · 0.45
Float64Method · 0.45
StringMethod · 0.45

Tested by

no test coverage detected