This commit is contained in:
fallen-angle
2022-01-20 16:49:37 +08:00
parent 2280679053
commit 582807ae10
13 changed files with 182 additions and 16 deletions

View File

@@ -1,6 +1,7 @@
package middleware
import (
"fmt"
"nCovTrack-Backend/utils"
"net"
"net/http"
@@ -33,7 +34,7 @@ func GinRecovery(stack bool) gin.HandlerFunc {
"error", interface{}(err),
)
if brokenPipe {
utils.RequestLogPanic(logParams...)
utils.RequestLogError(logParams...)
c.Error(err.(error))
c.Abort()
return
@@ -46,8 +47,9 @@ func GinRecovery(stack bool) gin.HandlerFunc {
"stack", string(debug.Stack()),
)
}
utils.RequestLogPanic(logParams...)
utils.RequestLogError(logParams...)
c.AbortWithStatus(http.StatusInternalServerError)
fmt.Printf("\n%s\n", debug.Stack())
}
}()
c.Next()

View File

@@ -31,7 +31,7 @@ func RequestLog() gin.HandlerFunc {
}
// Log while request cost an unexpected time;
if cost >= 800 {
if cost.Milliseconds() >= 800 {
logParams = append(logParams,
"status", c.Writer.Status(),
"query", c.Request.URL.Query(),