Download middleware/logger.go from AZILS/new-api: direct link, hf CLI and curl.
- Browser
- Download file 572 Bytes
-
https://huggingface.co/spaces/AZILS/new-api/resolve/main/middleware/logger.go
- Command line
-
hf download hf://spaces/AZILS/new-api/middleware/logger.go
-
curl -L -o logger.go https://huggingface.co/spaces/AZILS/new-api/resolve/main/middleware/logger.go
572 Bytes
| package middleware | |
| import ( | |
| "fmt" | |
| "github.com/QuantumNous/new-api/common" | |
| "github.com/gin-gonic/gin" | |
| ) | |
| func SetUpLogger(server *gin.Engine) { | |
| server.Use(gin.LoggerWithFormatter(func(param gin.LogFormatterParams) string { | |
| var requestID string | |
| if param.Keys != nil { | |
| requestID = param.Keys[common.RequestIdKey].(string) | |
| } | |
| return fmt.Sprintf("[GIN] %s | %s | %3d | %13v | %15s | %7s %s\n", | |
| param.TimeStamp.Format("2006/01/02 - 15:04:05"), | |
| requestID, | |
| param.StatusCode, | |
| param.Latency, | |
| param.ClientIP, | |
| param.Method, | |
| param.Path, | |
| ) | |
| })) | |
| } | |