mirror of
https://gitee.com/johng/gf
synced 2026-06-07 10:22:11 +08:00
去掉glog backtrace标准库调用记录
This commit is contained in:
@ -290,15 +290,15 @@ func (l *Logger) errPrint(s string) {
|
||||
|
||||
// 调用回溯字符串
|
||||
func (l *Logger) backtrace() string {
|
||||
backtrace := "Trace:\n"
|
||||
backtraces := []string{"Trace:"}
|
||||
for i := 1; i < 100; i++ {
|
||||
if _, cfile, cline, ok := runtime.Caller(i + 3); ok {
|
||||
backtrace += strconv.Itoa(i) + ". " + cfile + ":" + strconv.Itoa(cline) + "\n"
|
||||
backtraces = append(backtraces, strconv.Itoa(i) + ". " + cfile + ":" + strconv.Itoa(cline) + "\n")
|
||||
} else {
|
||||
break
|
||||
}
|
||||
}
|
||||
return backtrace
|
||||
return strings.Join(backtraces[0 : len(backtraces) -2 ], "\n")
|
||||
}
|
||||
|
||||
func (l *Logger) format(s string) string {
|
||||
|
||||
@ -2,7 +2,7 @@ package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"reflect"
|
||||
"gitee.com/johng/gf/g/os/glog"
|
||||
)
|
||||
|
||||
|
||||
@ -15,8 +15,5 @@ func (t *T)Test() {
|
||||
}
|
||||
|
||||
func main() {
|
||||
t := &T{"john"}
|
||||
//fmt.Printf("%p\n", t.Test)
|
||||
//fmt.Printf("%p\n", reflect.ValueOf(t).MethodByName("Test").Interface().(func()))
|
||||
reflect.ValueOf(t).MethodByName("Test").Interface().(func())()
|
||||
glog.Error("test")
|
||||
}
|
||||
Reference in New Issue
Block a user