diff --git a/middleware/distributor.go b/middleware/distributor.go index 0aceb29d..58ae0556 100644 --- a/middleware/distributor.go +++ b/middleware/distributor.go @@ -2,13 +2,15 @@ package middleware import ( "fmt" + "net/http" + "strconv" + "github.com/gin-gonic/gin" + "github.com/songquanpeng/one-api/common/ctxkey" "github.com/songquanpeng/one-api/common/logger" "github.com/songquanpeng/one-api/model" "github.com/songquanpeng/one-api/relay/channeltype" - "net/http" - "strconv" ) type ModelRequest struct { @@ -17,6 +19,7 @@ type ModelRequest struct { func Distribute() func(c *gin.Context) { return func(c *gin.Context) { + ctx := c.Request.Context() userId := c.GetInt(ctxkey.Id) userGroup, _ := model.CacheGetUserGroup(userId) c.Set(ctxkey.Group, userGroup) @@ -52,6 +55,7 @@ func Distribute() func(c *gin.Context) { return } } + logger.Debugf(ctx, "user id %d, user group: %s, request model: %s, using channel #%d", userId, userGroup, requestModel, channel.Id) SetupContextForSelectedChannel(c, channel, requestModel) c.Next() }