Hi all,
I'm working on quite complex project and time after time I have to narrow down problems looking at stack traces. They happen to be very long and involve “my” code, standard library code and 3rd party libraries code at same time. Most of time the real problem is in “my” code and locating it instantly in a stack trace is a bit hard for eyes. Under “my” code I mean the code that is under current working directory.
So I realized that I want something that will colorize stack traces and highlight lines that are mine. Compare original to highlighted.
I could write a python script that I could use this way:
nosetests | colorize_stack_trace.py
But I believe there is a quicker and more elegant way to do this using Linux toolset. Any ideas?
UPD:
Using supercat suggested by Dennis Williamson, the intermediate result is following bash function:
pyst() {
rc=/tmp/spcrc;
echo '#################### ### # # # ########################################' > $rc;
echo ' blk 0 r ^(.*)$' >> $rc;
echo ' mag b 0 r ^\s*File "'`pwd`'/(.*)"' >> $rc;
spc -c $rc;
}
Now I can do:
nosetests 2>&1 | pyst
Not too elegant, but works at some degree. There are two problems left:
- I can't see any output before nosetests completes. I.e. I don't see the progress.
- I have to write 2>&1 over and over again.
UPD 2:
Asking this question I had mainly nosetests
in mind. And I just found great solution: rednose nose plugin. It highlights paths that are local plus do many more handy readability things.
Returning to original question: problems that I noted with supercat don't relate to it completely but its a problem of Unix shell streaming, flushing, piping, redirecting. So as as an answer to the question asked I accept an answer that suggests supercat.