Commit 40b95f7b by 杨树贤

记录请求日志

parent 7b68309b
package logger
package logging
import (
"LC_soapi/pkg/setting"
......
package logger
package logging
import (
"LC_soapi/pkg/setting"
"LC_soapi/pkg/util"
"encoding/json"
"fmt"
"github.com/ichunt2019/logger"
"time"
)
......@@ -19,15 +22,22 @@ type ErrorLog struct {
}
//上报请求日志
func ReportErrorLog(msg string,code int,method string) {
func ReportErrorLog(msg string, code int, method string,ip string) {
var errLog ErrorLog
caller:=util.GetCaller(2);
fmt.Println(caller)
//获取调用者信息
caller := util.GetCaller(2)
errLog.TimeStamp = int(time.Now().Unix())
errLog.DateTimeStr = time.Now().Format("2006-01-02 15:04:05")
errLog.App = "Search"
errLog.ServerIp = "127.0.0.1"
errLog.App = setting.AppSetting.Name
errLog.ServerIp = ip
errLog.Method = "g.G.Routes()"
errLog.FileName = caller.FileName
errLog.LineNo = caller.FileLine
logString, _ := json.Marshal(errLog)
logger.Info(string(logString))
fmt.Println(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