|
@@ -4,6 +4,8 @@ import (
|
|
|
"github.com/lestrrat-go/file-rotatelogs"
|
|
|
"github.com/sirupsen/logrus"
|
|
|
"io"
|
|
|
+ "runtime"
|
|
|
+ "strconv"
|
|
|
"time"
|
|
|
)
|
|
|
|
|
@@ -57,3 +59,13 @@ func NewLogger(f io.Writer) *logrus.Logger {
|
|
|
log.Out = f
|
|
|
return log
|
|
|
}
|
|
|
+
|
|
|
+func GetErrorFuncInfo(skip int) string {
|
|
|
+ pc, file, lineNo, ok := runtime.Caller(skip)
|
|
|
+ if !ok {
|
|
|
+ return ""
|
|
|
+ }
|
|
|
+ funcName := runtime.FuncForPC(pc).Name()
|
|
|
+
|
|
|
+ return "文件名:" + file + " 行号:" + strconv.Itoa(lineNo) + " 方法名:" + funcName
|
|
|
+}
|