Skip to content
This repository has been archived by the owner on May 4, 2018. It is now read-only.

Commit

Permalink
Logger refactored.
Browse files Browse the repository at this point in the history
  • Loading branch information
Fabien Herfray committed Sep 28, 2015
1 parent 8b2352a commit e1b4840
Showing 1 changed file with 2 additions and 11 deletions.
13 changes: 2 additions & 11 deletions logger.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ type Logger struct {

// NewLogger returns a new Logger instance
func NewLogger() *Logger {
return &Logger{log.New(os.Stdout, "\n[Zest] ", 0)}
return &Logger{log.New(os.Stdout, "[Zest] ", 0)}
}

func (l *Logger) ServeHTTP(rw http.ResponseWriter, r *http.Request, next http.HandlerFunc) {
Expand All @@ -29,14 +29,6 @@ func (l *Logger) ServeHTTP(rw http.ResponseWriter, r *http.Request, next http.Ha
method := r.Method
methodColor := colorForMethod(method)

l.Printf("%s BEGIN %s | %v | %s | %s %s %s %s",
green, reset,
start.Format("2006/01/02 - 15:04:05"),
clientIP,
methodColor, method, reset,
path,
)

// process request
next(rw, r)

Expand All @@ -48,8 +40,7 @@ func (l *Logger) ServeHTTP(rw http.ResponseWriter, r *http.Request, next http.Ha
statusCode := res.Status()
statusColor := colorForStatus(statusCode)

l.Printf("%s END %s | %v | %s %3d %s | %v | %s | %s %s %s %s",
red, reset,
l.Printf("%v | %s %3d %s | %v | %s | %s %s %s %s",
end.Format("2006/01/02 - 15:04:05"),
statusColor, statusCode, reset,
latency,
Expand Down

0 comments on commit e1b4840

Please sign in to comment.