github.com/chrislusf/greenpack@v3.7.1-0.20170911073826-ad5bd10b7c47+incompatible/cmd/addzid/verbose.go (about) 1 package main 2 3 import ( 4 "fmt" 5 "time" 6 ) 7 8 // for debug output 9 var Verbose bool 10 11 // get timestamp for logging purposes 12 func ts() string { 13 return time.Now().Format("2006-01-02 15:04:05.999 -0700 MST") 14 } 15 16 // time-stamped printf 17 func TSPrintf(format string, a ...interface{}) { 18 fmt.Printf("%s ", ts()) 19 fmt.Printf(format, a...) 20 } 21 22 // print debug/status conditionally on having Verbose on 23 func VPrintf(format string, a ...interface{}) { 24 if Verbose { 25 TSPrintf("\n'"+format+"'\n", a...) 26 } 27 } 28 29 func p(format string, a ...interface{}) { 30 TSPrintf("\n"+format+"\n", a...) 31 }