Make sure log pipes are closed
Pipes are still not closed (and goroutines leaked) if neither pipe is used. Signed-off-by: Brian Goff <cpuguy83@gmail.com>
This commit is contained in:
parent
a15859d7a9
commit
9b30befa9d
1 changed files with 5 additions and 6 deletions
|
@ -5,8 +5,6 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/Sirupsen/logrus"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type JSONLog struct {
|
type JSONLog struct {
|
||||||
|
@ -37,15 +35,16 @@ func WriteLog(src io.Reader, dst io.Writer, format string, since time.Time) erro
|
||||||
l := &JSONLog{}
|
l := &JSONLog{}
|
||||||
for {
|
for {
|
||||||
l.Reset()
|
l.Reset()
|
||||||
if err := dec.Decode(l); err == io.EOF {
|
if err := dec.Decode(l); err != nil {
|
||||||
return nil
|
if err == io.EOF {
|
||||||
} else if err != nil {
|
return nil
|
||||||
logrus.Printf("Error streaming logs: %s", err)
|
}
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
if !since.IsZero() && l.Created.Before(since) {
|
if !since.IsZero() && l.Created.Before(since) {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
line, err := l.Format(format)
|
line, err := l.Format(format)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
|
Loading…
Reference in a new issue