diff --git a/internal/intlog/intlog.go b/internal/intlog/intlog.go index fb1f08af0..f5f3559c9 100644 --- a/internal/intlog/intlog.go +++ b/internal/intlog/intlog.go @@ -69,7 +69,11 @@ func PrintFunc(ctx context.Context, f func() string) { if !isGFDebug { return } - doPrint(ctx, fmt.Sprint(f()), false) + s := f() + if s == "" { + return + } + doPrint(ctx, s, false) } // ErrorFunc prints the output from function `f`. @@ -78,7 +82,11 @@ func ErrorFunc(ctx context.Context, f func() string) { if !isGFDebug { return } - doPrint(ctx, fmt.Sprint(f()), true) + s := f() + if s == "" { + return + } + doPrint(ctx, s, true) } func doPrint(ctx context.Context, content string, stack bool) { diff --git a/os/gtimer/gtimer_entry.go b/os/gtimer/gtimer_entry.go index 8a7cee2f8..beebf21a6 100644 --- a/os/gtimer/gtimer_entry.go +++ b/os/gtimer/gtimer_entry.go @@ -7,13 +7,8 @@ package gtimer import ( - "context" - "fmt" "github.com/gogf/gf/container/gtype" - "github.com/gogf/gf/internal/intlog" "math" - "reflect" - "runtime" ) // Entry is the timing job. @@ -61,13 +56,7 @@ func (entry *Entry) Run() { entry.SetStatus(StatusReady) } }() - intlog.PrintFunc(context.TODO(), func() string { - return fmt.Sprintf(`job start: %s`, runtime.FuncForPC(reflect.ValueOf(entry.job).Pointer()).Name()) - }) entry.job() - intlog.PrintFunc(context.TODO(), func() string { - return fmt.Sprintf(`job done: %s`, runtime.FuncForPC(reflect.ValueOf(entry.job).Pointer()).Name()) - }) }() }