Skip to content

Commit ea6360c

Browse files
committed
only print stack for FATAL and ERROR
1 parent c76b05e commit ea6360c

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

src/github.com/getlantern/golog/golog.go

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -163,16 +163,17 @@ func (l *logger) print(out io.Writer, skipFrames int, severity string, arg inter
163163
buf.WriteString(" ")
164164
buf.WriteString(linePrefix)
165165
if arg != nil {
166-
err, isError := arg.(errors.Error)
167-
if !isError {
168-
fmt.Fprintf(buf, "%v", arg)
166+
if err, isError := arg.(errors.Error); isError && err != nil {
167+
buf.WriteString(err.Error())
169168
printContext(buf, arg)
170169
buf.WriteByte('\n')
170+
if severity == "FATAL" || severity == "ERROR" {
171+
err.PrintStack(buf)
172+
}
171173
} else {
172-
buf.WriteString(err.Error())
174+
fmt.Fprintf(buf, "%v", arg)
173175
printContext(buf, arg)
174176
buf.WriteByte('\n')
175-
err.PrintStack(buf)
176177
}
177178
}
178179
b := []byte(hidden.Clean(buf.String()))

0 commit comments

Comments
 (0)