dip/vendor/github.com/markbates/oncer/log_debug.go

20 lines
260 B
Go
Raw Normal View History

2020-01-26 16:38:57 +01:00
//+build debug
package oncer
import (
"fmt"
"time"
)
func log(name string, fn func()) func() {
return func() {
start := time.Now()
if len(name) > 80 {
name = name[(len(name) - 80):]
}
defer fmt.Println(name, time.Now().Sub(start))
fn()
}
}