去掉glog backtrace标准库调用记录

This commit is contained in:
John
2018-01-09 14:06:39 +08:00
parent 220cd6f1f8
commit 58fb9e94de
2 changed files with 5 additions and 8 deletions

View File

@ -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 {

View File

@ -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")
}