Adding some debug options
This commit is contained in:
15
pkg/utils/logging.go
Normal file
15
pkg/utils/logging.go
Normal file
@ -0,0 +1,15 @@
|
||||
package utils
|
||||
|
||||
import (
|
||||
"log"
|
||||
"time"
|
||||
)
|
||||
|
||||
//LogElapsedTime provides a function that can be used to log the time elapsed between when this function is invoked, to the time the returned function is invoked.
|
||||
//Adding "defer LogElapsedTime("my log")" at the beginning of any function will log the time it takes to execute that function.
|
||||
func LogElapsedTime(what string) func() {
|
||||
start := time.Now()
|
||||
return func() {
|
||||
log.Printf("%s, Total Time Taken: %v\n", what, time.Since(start))
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user