init
This commit is contained in:
20
middlewares/logger.go
Normal file
20
middlewares/logger.go
Normal file
@@ -0,0 +1,20 @@
|
||||
package middlewares
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
func Logger() gin.HandlerFunc {
|
||||
return gin.LoggerWithFormatter(func(param gin.LogFormatterParams) string {
|
||||
return fmt.Sprintf("%s - [%s] %s %s %d %s\n",
|
||||
param.ClientIP,
|
||||
param.TimeStamp.Format(time.RFC822),
|
||||
param.Method,
|
||||
param.Path,
|
||||
param.StatusCode,
|
||||
param.Latency)
|
||||
})
|
||||
}
|
||||
Reference in New Issue
Block a user