mirror of
https://github.com/gin-gonic/gin.git
synced 2025-08-06 15:50:30 +08:00
Initial commit
This commit is contained in:
20
logger.go
Normal file
20
logger.go
Normal file
@ -0,0 +1,20 @@
|
||||
package gin
|
||||
|
||||
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.Writer.Status(), c.Req.RequestURI, time.Since(t))
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user