feat: 建立可观测性、容量与恢复验证基线
This commit is contained in:
@@ -2,6 +2,7 @@ package middleware
|
||||
|
||||
import (
|
||||
"log/slog"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
@@ -17,13 +18,22 @@ func Logger() gin.HandlerFunc {
|
||||
|
||||
latency := time.Since(start)
|
||||
status := c.Writer.Status()
|
||||
query := RedactSensitiveQuery(c.Request.URL.RawQuery)
|
||||
auth := c.GetHeader("Authorization")
|
||||
authPrefix := ""
|
||||
if auth != "" {
|
||||
authPrefix = strings.SplitN(auth, " ", 2)[0]
|
||||
}
|
||||
|
||||
slog.Info("请求",
|
||||
"requestId", RequestID(c),
|
||||
"method", c.Request.Method,
|
||||
"path", path,
|
||||
"query", query,
|
||||
"status", status,
|
||||
"latency", latency.String(),
|
||||
"ip", c.ClientIP(),
|
||||
"authType", authPrefix,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user