From c19f1e5eed202e5e480fb05bc06764c0f92596b8 Mon Sep 17 00:00:00 2001 From: Rafael Passos Date: Fri, 25 May 2018 18:45:33 -0300 Subject: [PATCH] Diode module Documentation update (#71) * Updated Diode example to match new style * DOC: changed w to wr in assigment to reduce ambiguity --- README.md | 7 +++---- diode/diode.go | 5 +++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 6e402e5..082cd39 100644 --- a/README.md +++ b/README.md @@ -298,10 +298,9 @@ log.Logger = log.With().Str("foo", "bar").Logger() If your writer might be slow or not thread-safe and you need your log producers to never get slowed down by a slow writer, you can use a `diode.Writer` as follow: ```go -d := diodes.NewManyToOne(1000, diodes.AlertFunc(func(missed int) { - fmt.Printf("Dropped %d messages\n", missed) -})) -w := diode.NewWriter(os.Stdout, d, 10*time.Millisecond) +wr := diode.NewWriter(os.Stdout, 1000, 10*time.Millisecond, func(missed int) { + fmt.Printf("Logger Dropped %d messages", missed) + }) log := zerolog.New(w) log.Print("test") ``` diff --git a/diode/diode.go b/diode/diode.go index a720f0b..8711ee5 100644 --- a/diode/diode.go +++ b/diode/diode.go @@ -35,10 +35,11 @@ type Writer struct { // // Use a diode.Writer when // -// w := diode.NewWriter(w, 1000, 10 * time.Millisecond, func(missed int) { +// wr := diode.NewWriter(w, 1000, 10 * time.Millisecond, func(missed int) { // log.Printf("Dropped %d messages", missed) // }) -// log := zerolog.New(w) +// log := zerolog.New(wr) +// // // See code.cloudfoundry.org/go-diodes for more info on diode. func NewWriter(w io.Writer, size int, poolInterval time.Duration, f Alerter) Writer {