mirror of
https://gitee.com/dromara/mayfly-go
synced 2025-12-15 12:16:34 +08:00
refactor: slog替换logrus、日志操作统一、支持json、text格式等
This commit is contained in:
@@ -3,12 +3,11 @@ package ginx
|
||||
import (
|
||||
"io"
|
||||
"mayfly-go/pkg/biz"
|
||||
"mayfly-go/pkg/global"
|
||||
"mayfly-go/pkg/logx"
|
||||
"mayfly-go/pkg/model"
|
||||
"mayfly-go/pkg/utils/structx"
|
||||
"mayfly-go/pkg/validatorx"
|
||||
"net/http"
|
||||
"runtime/debug"
|
||||
"strconv"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
@@ -105,12 +104,10 @@ func ErrorRes(g *gin.Context, err any) {
|
||||
g.JSON(http.StatusOK, model.Error(t))
|
||||
case error:
|
||||
g.JSON(http.StatusOK, model.ServerError())
|
||||
global.Log.Errorf("%s\n%s", t.Error(), string(debug.Stack()))
|
||||
case string:
|
||||
g.JSON(http.StatusOK, model.ServerError())
|
||||
global.Log.Errorf("%s\n%s", t, string(debug.Stack()))
|
||||
default:
|
||||
global.Log.Error(t)
|
||||
logx.Error("未知错误", "errInfo", t)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user