From 9b30befa9d0e62da444bca702f037a3ac5bc844e Mon Sep 17 00:00:00 2001 From: Brian Goff Date: Wed, 6 May 2015 21:09:27 -0400 Subject: [PATCH] Make sure log pipes are closed Pipes are still not closed (and goroutines leaked) if neither pipe is used. Signed-off-by: Brian Goff --- jsonlog/jsonlog.go | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/jsonlog/jsonlog.go b/jsonlog/jsonlog.go index ce2da4a..85afb3b 100644 --- a/jsonlog/jsonlog.go +++ b/jsonlog/jsonlog.go @@ -5,8 +5,6 @@ import ( "fmt" "io" "time" - - "github.com/Sirupsen/logrus" ) type JSONLog struct { @@ -37,15 +35,16 @@ func WriteLog(src io.Reader, dst io.Writer, format string, since time.Time) erro l := &JSONLog{} for { l.Reset() - if err := dec.Decode(l); err == io.EOF { - return nil - } else if err != nil { - logrus.Printf("Error streaming logs: %s", err) + if err := dec.Decode(l); err != nil { + if err == io.EOF { + return nil + } return err } if !since.IsZero() && l.Created.Before(since) { continue } + line, err := l.Format(format) if err != nil { return err