2024-09-13 15:57:29 +08:00
|
|
|
package middleware
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
"github.com/gin-gonic/gin"
|
2025-02-12 19:46:39 +08:00
|
|
|
"github.com/lejianwen/rustdesk-api/v2/global"
|
2024-09-13 15:57:29 +08:00
|
|
|
"github.com/sirupsen/logrus"
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
// Logger 日志中间件
|
|
|
|
|
func Logger() gin.HandlerFunc {
|
|
|
|
|
return func(c *gin.Context) {
|
|
|
|
|
global.Logger.WithFields(
|
|
|
|
|
logrus.Fields{
|
|
|
|
|
"uri": c.Request.URL,
|
|
|
|
|
"ip": c.ClientIP(),
|
|
|
|
|
"method": c.Request.Method,
|
|
|
|
|
}).Debug("Request")
|
|
|
|
|
c.Next()
|
|
|
|
|
}
|
|
|
|
|
}
|