diff --git a/jsonlog/jsonlog.go b/jsonlog/jsonlog.go index 16d015f..b0c61a8 100644 --- a/jsonlog/jsonlog.go +++ b/jsonlog/jsonlog.go @@ -25,11 +25,16 @@ func (jl *JSONLog) Format(format string) (string, error) { return fmt.Sprintf("[%s] %s", jl.Created.Format(format), jl.Log), nil } +func (jl *JSONLog) Reset() { + jl.Log = "" + jl.Stream = "" + jl.Created = time.Time{} +} + func WriteLog(src io.Reader, dst io.Writer, format string) error { dec := json.NewDecoder(src) + l := &JSONLog{} for { - l := &JSONLog{} - if err := dec.Decode(l); err == io.EOF { return nil } else if err != nil { @@ -43,5 +48,6 @@ func WriteLog(src io.Reader, dst io.Writer, format string) error { if _, err := io.WriteString(dst, line); err != nil { return err } + l.Reset() } }