Skip to content

Commit

Permalink
refactory generate log
Browse files Browse the repository at this point in the history
  • Loading branch information
philchia committed Dec 28, 2016
1 parent 200e7f8 commit ff9c0ea
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
5 changes: 1 addition & 4 deletions gollog.go
Expand Up @@ -39,10 +39,7 @@ func (l *gollog) put(buf *bytes.Buffer) {
}

func (l *gollog) output(callDepth int, level LogLevel, msg string) {
buf := bufferPoolGet()
l.generateLog(buf, callDepth, level, msg)

l.put(buf)
l.put(l.generateLog(callDepth, level, msg))
}

// Debug will prinnt log as DEBUG level
Expand Down
4 changes: 3 additions & 1 deletion gollogOption.go
Expand Up @@ -97,7 +97,8 @@ func getCaller(depth int) (file string, line int) {
return
}

func (l *gollog) generateLog(buf *bytes.Buffer, callDepth int, level LogLevel, msg string) {
func (l *gollog) generateLog(callDepth int, level LogLevel, msg string) *bytes.Buffer {
buf := bufferPoolGet()
l.generatePrefix(buf, callDepth)

buf.Write(level.ColorString())
Expand All @@ -106,4 +107,5 @@ func (l *gollog) generateLog(buf *bytes.Buffer, callDepth int, level LogLevel, m
buf.WriteByte(' ')
buf.WriteString(msg)
buf.WriteByte('\n')
return buf
}

0 comments on commit ff9c0ea

Please sign in to comment.