Adding some debug options
This commit is contained in:
1 parent
43ed2ea438
commit
d98ac3058e
3 files changed
+21
-2
No files matched your search
@@ -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