Commit 1dadd8a3 by 杨树贤

完善日志格式

parent 40b95f7b
package app
package http
import (
"LC_soapi/pkg/logging"
"github.com/gin-gonic/gin"
)
......@@ -15,10 +16,15 @@ type Response struct {
}
// Response setting gin.JSON
func (g *Gin) Response(errCode int, errMsg string, data interface{}) {
func (g *Gin) Response(code int, msg string, data interface{}) {
if code > 100 {
logging.ReportErrorLog(code, msg, g.C.ClientIP())
}
g.C.JSON(200, Response{
Code: errCode,
Msg: errMsg,
Code: code,
Msg: msg,
Data: data,
})
return
......
......@@ -22,7 +22,7 @@ type ErrorLog struct {
}
//上报请求日志
func ReportErrorLog(msg string, code int, method string,ip string) {
func ReportErrorLog(code int, msg string, ip string) {
var errLog ErrorLog
//获取调用者信息
caller := util.GetCaller(2)
......@@ -32,7 +32,7 @@ func ReportErrorLog(msg string, code int, method string,ip string) {
errLog.App = setting.AppSetting.Name
errLog.ServerIp = ip
errLog.Method = "g.G.Routes()"
errLog.Method = caller.FunctionName
errLog.FileName = caller.FileName
errLog.LineNo = caller.FileLine
logString, _ := json.Marshal(errLog)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment