修改日志初始化值,level值不被覆盖

This commit is contained in:
linwenxiang
2020-10-09 16:15:51 +08:00
parent 4fe68183ba
commit faa8de7dc2
3 changed files with 7 additions and 7 deletions
+3 -3
View File
@@ -27,7 +27,7 @@ func (e *Api) Error(c *gin.Context, code int, err error, msg string) {
res.Msg = msg res.Msg = msg
} }
res.RequestId = tools.GenerateMsgIDFromContext(c) res.RequestId = tools.GenerateMsgIDFromContext(c)
c.JSON(http.StatusOK, res.ReturnError(code)) c.AbortWithStatusJSON(http.StatusOK, res.ReturnError(code))
} }
// OK 通常成功数据处理 // OK 通常成功数据处理
@@ -38,7 +38,7 @@ func (e *Api) OK(c *gin.Context, data interface{}, msg string) {
res.Msg = msg res.Msg = msg
} }
res.RequestId = tools.GenerateMsgIDFromContext(c) res.RequestId = tools.GenerateMsgIDFromContext(c)
c.JSON(http.StatusOK, res.ReturnOK()) c.AbortWithStatusJSON(http.StatusOK, res.ReturnOK())
} }
// PageOK 分页数据处理 // PageOK 分页数据处理
@@ -53,5 +53,5 @@ func (e *Api) PageOK(c *gin.Context, result interface{}, count int, pageIndex in
// Custom 兼容函数 // Custom 兼容函数
func (e *Api) Custom(c *gin.Context, data gin.H) { func (e *Api) Custom(c *gin.Context, data gin.H) {
c.JSON(http.StatusOK, data) c.AbortWithStatusJSON(http.StatusOK, data)
} }
+1 -1
View File
@@ -3,7 +3,7 @@ package logger
var ( var (
// Default logger // Default logger
DefaultLogger Logger = NewHelper(NewLogger()) DefaultLogger Logger
) )
// Logger is a generic logging interface // Logger is a generic logging interface
+3 -3
View File
@@ -18,7 +18,7 @@ func Error(c *gin.Context, code int, err error, msg string) {
res.Msg = msg res.Msg = msg
} }
res.RequestId = tools.GenerateMsgIDFromContext(c) res.RequestId = tools.GenerateMsgIDFromContext(c)
c.JSON(http.StatusOK, res.ReturnError(code)) c.AbortWithStatusJSON(http.StatusOK, res.ReturnError(code))
} }
// 通常成功数据处理 // 通常成功数据处理
@@ -29,7 +29,7 @@ func OK(c *gin.Context, data interface{}, msg string) {
res.Msg = msg res.Msg = msg
} }
res.RequestId = tools.GenerateMsgIDFromContext(c) res.RequestId = tools.GenerateMsgIDFromContext(c)
c.JSON(http.StatusOK, res.ReturnOK()) c.AbortWithStatusJSON(http.StatusOK, res.ReturnOK())
} }
// 分页数据处理 // 分页数据处理
@@ -44,5 +44,5 @@ func PageOK(c *gin.Context, result interface{}, count int, pageIndex int, pageSi
// 兼容函数 // 兼容函数
func Custum(c *gin.Context, data gin.H) { func Custum(c *gin.Context, data gin.H) {
c.JSON(http.StatusOK, data) c.AbortWithStatusJSON(http.StatusOK, data)
} }