| 87 | } |
| 88 | |
| 89 | func 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 | |
| 104 | func TestConsoleWriter(t *testing.T) { |
| 105 | t.Run("Default field formatter", func(t *testing.T) { |