go-logging(停止维护了)替换成zap, zap的配置完善优化,gva的日志更换zap后的处理
This commit is contained in:
@@ -30,7 +30,7 @@ func GinRecovery(stack bool) gin.HandlerFunc {
|
||||
|
||||
httpRequest, _ := httputil.DumpRequest(c.Request, false)
|
||||
if brokenPipe {
|
||||
global.GVA_ZAP.Error(c.Request.URL.Path,
|
||||
global.GVA_LOG.Error(c.Request.URL.Path,
|
||||
zap.Any("error", err),
|
||||
zap.String("request", string(httpRequest)),
|
||||
)
|
||||
@@ -41,13 +41,13 @@ func GinRecovery(stack bool) gin.HandlerFunc {
|
||||
}
|
||||
|
||||
if stack {
|
||||
global.GVA_ZAP.Error("[Recovery from panic]",
|
||||
global.GVA_LOG.Error("[Recovery from panic]",
|
||||
zap.Any("error", err),
|
||||
zap.String("request", string(httpRequest)),
|
||||
zap.String("stack", string(debug.Stack())),
|
||||
)
|
||||
} else {
|
||||
global.GVA_ZAP.Error("[Recovery from panic]",
|
||||
global.GVA_LOG.Error("[Recovery from panic]",
|
||||
zap.Any("error", err),
|
||||
zap.String("request", string(httpRequest)),
|
||||
)
|
||||
|
@@ -9,6 +9,7 @@ import (
|
||||
"gin-vue-admin/service"
|
||||
"github.com/dgrijalva/jwt-go"
|
||||
"github.com/gin-gonic/gin"
|
||||
"go.uber.org/zap"
|
||||
"strconv"
|
||||
"time"
|
||||
)
|
||||
@@ -57,7 +58,7 @@ func JWTAuth() gin.HandlerFunc {
|
||||
if global.GVA_CONFIG.System.UseMultipoint {
|
||||
err,RedisJwtToken := service.GetRedisJWT(newClaims.Username)
|
||||
if err!=nil {
|
||||
global.GVA_LOG.Error(err)
|
||||
global.GVA_LOG.Error("get redis jwt failed", zap.Any("err", err))
|
||||
}else{
|
||||
service.JsonInBlacklist(model.JwtBlacklist{Jwt: RedisJwtToken})
|
||||
//当之前的取成功时才进行拉黑操作
|
||||
|
@@ -6,6 +6,7 @@ import (
|
||||
"gin-vue-admin/model"
|
||||
"gin-vue-admin/service"
|
||||
"github.com/gin-gonic/gin"
|
||||
"go.uber.org/zap"
|
||||
"io/ioutil"
|
||||
"net/http"
|
||||
"strconv"
|
||||
@@ -19,7 +20,7 @@ func OperationRecord() gin.HandlerFunc {
|
||||
var err error
|
||||
body, err = ioutil.ReadAll(c.Request.Body)
|
||||
if err != nil {
|
||||
global.GVA_LOG.Error("read body from request error:", err)
|
||||
global.GVA_LOG.Error("read body from request error:", zap.Any("err", err))
|
||||
} else {
|
||||
c.Request.Body = ioutil.NopCloser(bytes.NewBuffer(body))
|
||||
}
|
||||
@@ -52,7 +53,7 @@ func OperationRecord() gin.HandlerFunc {
|
||||
record.Resp = writer.body.String()
|
||||
|
||||
if err := service.CreateSysOperationRecord(record); err != nil {
|
||||
global.GVA_LOG.Error("create operation record error:", err)
|
||||
global.GVA_LOG.Error("create operation record error:", zap.Any("err", err))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user