Skip to content

Commit

Permalink
deduplicate golog code
Browse files Browse the repository at this point in the history
  • Loading branch information
fffw committed Aug 16, 2016
1 parent 8298106 commit c76b05e
Showing 1 changed file with 3 additions and 7 deletions.
10 changes: 3 additions & 7 deletions src/github.com/getlantern/golog/golog.go
Original file line number Diff line number Diff line change
Expand Up @@ -159,20 +159,16 @@ func (l *logger) print(out io.Writer, skipFrames int, severity string, arg inter
defer bufferPool.Put(buf)

linePrefix := l.linePrefix(skipFrames)
writeHeader := func() {
buf.WriteString(severity)
buf.WriteString(" ")
buf.WriteString(linePrefix)
}
buf.WriteString(severity)
buf.WriteString(" ")
buf.WriteString(linePrefix)
if arg != nil {
err, isError := arg.(errors.Error)
if !isError {
writeHeader()
fmt.Fprintf(buf, "%v", arg)
printContext(buf, arg)
buf.WriteByte('\n')
} else {
writeHeader()
buf.WriteString(err.Error())
printContext(buf, arg)
buf.WriteByte('\n')
Expand Down

0 comments on commit c76b05e

Please sign in to comment.