mirror of
https://github.com/geektutu/7days-golang.git
synced 2024-04-21 12:32:11 +00:00
18 lines
275 B
Go
18 lines
275 B
Go
package gee
|
|
|
|
import (
|
|
"log"
|
|
"time"
|
|
)
|
|
|
|
func Logger() HandlerFunc {
|
|
return func(c *Context) {
|
|
// Start timer
|
|
t := time.Now()
|
|
// Process request
|
|
c.Next()
|
|
// Calculate resolution time
|
|
log.Printf("[%d] %s in %v", c.StatusCode, c.Req.RequestURI, time.Since(t))
|
|
}
|
|
}
|