go-stack / stack

Package stack implements utilities to capture, manipulate, and format call stacks.
MIT License
397 stars 34 forks source link

Add line source code at each frame of stack? #1

Closed mgutz closed 9 years ago

mgutz commented 9 years ago

This library is great. Would be nice to see the actual line's source code at each frame with context lines. Here's an example of one I did on node.js to help my team troubleshoot faster

https://raw.githubusercontent.com/barc/express-error/master/img/stack.png

I sometimes see error line when an error is wrapped.

ChrisHines commented 9 years ago

Thanks.

Do you have any suggestions for how to implement this idea? The source code is not usually available once a Go binary is running in production.

mgutz commented 9 years ago

I wouldn't use it in production only while developing. It would slow things down too much to be of any use in production.

ChrisHines commented 9 years ago

I can see how that might be useful, but it is out of scope for this package. Perhaps you could write a utility that uses the source file and line number information from stack to do what you want.

mgutz commented 9 years ago

no problem. you can see how useful the context is on error on this gifcast https://github.com/mgutz/logxi. saves alot of time.