logging: mark antigravity credits requests
This commit is contained in:
@@ -27,7 +27,10 @@ var aiAPIPrefixes = []string{
|
|||||||
"/api/provider/",
|
"/api/provider/",
|
||||||
}
|
}
|
||||||
|
|
||||||
const skipGinLogKey = "__gin_skip_request_logging__"
|
const (
|
||||||
|
skipGinLogKey = "__gin_skip_request_logging__"
|
||||||
|
creditsUsedKey = "__antigravity_credits_used__"
|
||||||
|
)
|
||||||
|
|
||||||
// GinLogrusLogger returns a Gin middleware handler that logs HTTP requests and responses
|
// GinLogrusLogger returns a Gin middleware handler that logs HTTP requests and responses
|
||||||
// using logrus. It captures request details including method, path, status code, latency,
|
// using logrus. It captures request details including method, path, status code, latency,
|
||||||
@@ -79,6 +82,9 @@ func GinLogrusLogger() gin.HandlerFunc {
|
|||||||
requestID = "--------"
|
requestID = "--------"
|
||||||
}
|
}
|
||||||
logLine := fmt.Sprintf("%3d | %13v | %15s | %-7s \"%s\"", statusCode, latency, clientIP, method, path)
|
logLine := fmt.Sprintf("%3d | %13v | %15s | %-7s \"%s\"", statusCode, latency, clientIP, method, path)
|
||||||
|
if creditsUsed(c) {
|
||||||
|
logLine += " [credits]"
|
||||||
|
}
|
||||||
if errorMessage != "" {
|
if errorMessage != "" {
|
||||||
logLine = logLine + " | " + errorMessage
|
logLine = logLine + " | " + errorMessage
|
||||||
}
|
}
|
||||||
@@ -149,3 +155,15 @@ func shouldSkipGinRequestLogging(c *gin.Context) bool {
|
|||||||
flag, ok := val.(bool)
|
flag, ok := val.(bool)
|
||||||
return ok && flag
|
return ok && flag
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func creditsUsed(c *gin.Context) bool {
|
||||||
|
if c == nil {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
val, exists := c.Get(creditsUsedKey)
|
||||||
|
if !exists {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
flag, ok := val.(bool)
|
||||||
|
return ok && flag
|
||||||
|
}
|
||||||
|
|||||||
@@ -2242,9 +2242,9 @@ var antigravityBaseURLFallbackOrder = func(auth *cliproxyauth.Auth) []string {
|
|||||||
return []string{base}
|
return []string{base}
|
||||||
}
|
}
|
||||||
return []string{
|
return []string{
|
||||||
antigravityBaseURLProd,
|
|
||||||
antigravityBaseURLDaily,
|
antigravityBaseURLDaily,
|
||||||
antigravitySandboxBaseURLDaily,
|
antigravityBaseURLProd,
|
||||||
|
// antigravitySandboxBaseURLDaily,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user