The language developers are not keen on allowing programmers to know which goroutine their code is running in for “it’s abusive power” of being able to use it to implement goroutine-local-storage.
It appears that the only solution logging-wise is to pass common data along the function calls. People usually accomplish this by having some kind central structure that’s given to passed onto every function. One such is: go.net/context.
Hopefully my comment wasn’t completely off-topic.
> Use a dead-simple type wrapping the standard logger; create and use an
> instance of it in each goroutine: [1].
Sorry, forgot to include the playground link:
http://play.golang.org/p/DWhYqdG8LH
The language developers are not keen on allowing programmers to know which goroutine their code is running in for “it’s abusive power” of being able to use it to implement goroutine-local-storage.
It appears that the only solution logging-wise is to pass common data along the function calls. People usually accomplish this by having some kind central structure that’s given to passed onto every function. One such is: go.net/context.
Well, this http://play.golang.org/p/-ypqnGA-Bt would work as a poor
man's solution to the stated problem.
Of course, this is not really a solution but this is at least something.
Still, I'm inclined to think the OP is going against the grain and
would be better off solving real problem rather than trying to mess
with logging.
Doesn't glog print line numbers? It is usually sufficient for me.
--
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...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.