2018-03-28 18:49:41 +00:00
|
|
|
// +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"
|
2018-03-28 18:49:41 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
func ExampleNewWriter() {
|
2018-10-31 23:57:15 +00:00
|
|
|
w := diode.NewWriter(os.Stdout, 1000, 0, func(missed int) {
|
2018-03-28 18:49:41 +00:00
|
|
|
fmt.Printf("Dropped %d messages\n", missed)
|
2018-05-25 01:50:57 +00:00
|
|
|
})
|
2022-03-20 19:19:42 +00:00
|
|
|
log := zlog.New(w)
|
2018-03-28 18:49:41 +00:00
|
|
|
log.Print("test")
|
|
|
|
|
|
|
|
w.Close()
|
|
|
|
|
|
|
|
// Output: {"level":"debug","message":"test"}
|
|
|
|
}
|