zlog/diode/diode_example_test.go

24 lines
351 B
Go
Raw Normal View History

// +build !binary_log
package diode_test
import (
"fmt"
"os"
2022-11-03 15:18:09 +00:00
"tuxpa.in/a/zlog"
"tuxpa.in/a/zlog/diode"
)
func ExampleNewWriter() {
w := diode.NewWriter(os.Stdout, 1000, 0, func(missed int) {
fmt.Printf("Dropped %d messages\n", missed)
})
2022-03-20 19:19:42 +00:00
log := zlog.New(w)
log.Print("test")
w.Close()
// Output: {"level":"debug","message":"test"}
}