mirror of https://github.com/sirupsen/logrus.git
Switching to io.MultiWriter for clarity
This commit is contained in:
parent
ced531341e
commit
f302a46d2a
7
entry.go
7
entry.go
|
@ -71,6 +71,8 @@ func (entry *Entry) WithFields(fields Fields) *Entry {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (entry *Entry) log(level Level, msg string) {
|
func (entry *Entry) log(level Level, msg string) {
|
||||||
|
var panicBuf bytes.Buffer
|
||||||
|
|
||||||
entry.Time = time.Now()
|
entry.Time = time.Now()
|
||||||
entry.Level = level
|
entry.Level = level
|
||||||
entry.Message = msg
|
entry.Message = msg
|
||||||
|
@ -88,13 +90,10 @@ func (entry *Entry) log(level Level, msg string) {
|
||||||
entry.Logger.mu.Unlock()
|
entry.Logger.mu.Unlock()
|
||||||
}
|
}
|
||||||
|
|
||||||
var panicBuf bytes.Buffer
|
|
||||||
teeOut := io.TeeReader(reader, &panicBuf)
|
|
||||||
|
|
||||||
entry.Logger.mu.Lock()
|
entry.Logger.mu.Lock()
|
||||||
defer entry.Logger.mu.Unlock()
|
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 {
|
if err != nil {
|
||||||
fmt.Fprintf(os.Stderr, "Failed to write to log, %v\n", err)
|
fmt.Fprintf(os.Stderr, "Failed to write to log, %v\n", err)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue