Commit 40b95f7b by 杨树贤

记录请求日志

parent 7b68309b
package logger package logging
import ( import (
"LC_soapi/pkg/setting" "LC_soapi/pkg/setting"
......
package logger package logging
import ( import (
"LC_soapi/pkg/setting"
"LC_soapi/pkg/util" "LC_soapi/pkg/util"
"encoding/json"
"fmt" "fmt"
"github.com/ichunt2019/logger"
"time" "time"
) )
...@@ -19,15 +22,22 @@ type ErrorLog struct { ...@@ -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 var errLog ErrorLog
//获取调用者信息
caller:=util.GetCaller(2); caller := util.GetCaller(2)
fmt.Println(caller)
errLog.TimeStamp = int(time.Now().Unix()) errLog.TimeStamp = int(time.Now().Unix())
errLog.DateTimeStr = time.Now().Format("2006-01-02 15:04:05") errLog.DateTimeStr = time.Now().Format("2006-01-02 15:04:05")
errLog.App = "Search" errLog.App = setting.AppSetting.Name
errLog.ServerIp = "127.0.0.1"
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