29 lines
560 B
Go
29 lines
560 B
Go
|
package log
|
||
|
|
||
|
import (
|
||
|
"fmt"
|
||
|
"time"
|
||
|
)
|
||
|
|
||
|
// 跟踪时间
|
||
|
|
||
|
func DebuglnTrackTime(do func(), fargs ...interface{}) {
|
||
|
now := time.Now()
|
||
|
do()
|
||
|
var t interface{} = fmt.Sprintf("[%dms]", time.Since(now).Milliseconds())
|
||
|
var out []interface{}
|
||
|
out = append(out, t)
|
||
|
out = append(out, fargs...)
|
||
|
l.Debugln(out...)
|
||
|
}
|
||
|
|
||
|
func InfolnTrackTime(do func(), fargs ...interface{}) {
|
||
|
now := time.Now()
|
||
|
do()
|
||
|
var t interface{} = fmt.Sprintf("[%dms]", time.Since(now).Milliseconds())
|
||
|
var out []interface{}
|
||
|
out = append(out, t)
|
||
|
out = append(out, fargs...)
|
||
|
l.Infoln(out...)
|
||
|
}
|