diff --git a/entry.go b/entry.go index dc639b3..80638f3 100644 --- a/entry.go +++ b/entry.go @@ -71,6 +71,8 @@ func (entry *Entry) WithFields(fields Fields) *Entry { } func (entry *Entry) log(level Level, msg string) { + var panicBuf bytes.Buffer + entry.Time = time.Now() entry.Level = level entry.Message = msg @@ -88,13 +90,10 @@ func (entry *Entry) log(level Level, msg string) { entry.Logger.mu.Unlock() } - var panicBuf bytes.Buffer - teeOut := io.TeeReader(reader, &panicBuf) - entry.Logger.mu.Lock() defer entry.Logger.mu.Unlock() - _, err = io.Copy(entry.Logger.Out, teeOut) + _, err = io.Copy(io.MultiWriter(entry.Logger.Out, &panicBuf), reader) if err != nil { fmt.Fprintf(os.Stderr, "Failed to write to log, %v\n", err) }