Switching to io.MultiWriter for clarity

This commit is contained in:
Dan Buch 2014-11-05 14:07:40 -05:00
parent ced531341e
commit f302a46d2a
1 changed files with 3 additions and 4 deletions

View File

@ -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)
}