I write logs into one single log file.
and need to set a different tracking id for each goroutine.
But I don't want to pass the tracking id argument for all functions.


func main() {
  go Func()
}
func Func() {
  SetLogTrackId("xxxx")
  LogDebug("123")
  call1()
}
func call1() {
   LogDebug("call1")
}
var trackId string //need this scope to be goroutine scope
func SetLogTrackId(id string) {
    trackId = id
}
func LogDebug(v ...interface{}) {
    log.Println("DEBUG " + trackId + " " + fmt.Sprintln(v...))
}


-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/798a4565-5f1c-4495-8589-3575ba52953a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to