()
| 70 | } |
| 71 | |
| 72 | func ExampleNewConsoleWriter_customFormatters() { |
| 73 | out := zerolog.NewConsoleWriter( |
| 74 | func(w *zerolog.ConsoleWriter) { |
| 75 | // Customize time format |
| 76 | w.TimeFormat = time.RFC822 |
| 77 | // Customize level formatting |
| 78 | w.FormatLevel = func(i interface{}) string { return strings.ToUpper(fmt.Sprintf("[%-5s]", i)) } |
| 79 | }, |
| 80 | ) |
| 81 | out.NoColor = true // For testing purposes only |
| 82 | |
| 83 | log := zerolog.New(out) |
| 84 | |
| 85 | log.Info().Str("foo", "bar").Msg("Hello World") |
| 86 | // Output: <nil> [INFO ] Hello World foo=bar |
| 87 | } |
| 88 | |
| 89 | func TestConsoleLogger(t *testing.T) { |
| 90 | t.Run("Numbers", func(t *testing.T) { |
nothing calls this directly
no test coverage detected