diff --git a/g/os/glog/glog.go b/g/os/glog/glog.go index 147078570..a4ea064a2 100644 --- a/g/os/glog/glog.go +++ b/g/os/glog/glog.go @@ -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 { diff --git a/geg/other/test.go b/geg/other/test.go index 78b08c12b..49ba03def 100644 --- a/geg/other/test.go +++ b/geg/other/test.go @@ -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") } \ No newline at end of file