...

Source file src/github.com/rs/zerolog/diode/diode_example_test.go

Documentation: github.com/rs/zerolog/diode

     1  // +build !binary_log
     2  
     3  package diode_test
     4  
     5  import (
     6  	"fmt"
     7  	"os"
     8  
     9  	"github.com/rs/zerolog"
    10  	"github.com/rs/zerolog/diode"
    11  )
    12  
    13  func ExampleNewWriter() {
    14  	w := diode.NewWriter(os.Stdout, 1000, 0, func(missed int) {
    15  		fmt.Printf("Dropped %d messages\n", missed)
    16  	})
    17  	log := zerolog.New(w)
    18  	log.Print("test")
    19  
    20  	w.Close()
    21  
    22  	// Output: {"level":"debug","message":"test"}
    23  }
    24  

View as plain text