Open julian-goettingen opened 1 year ago
Hi, sorry for the long delay. That (html + clickable 'downloads' of the full variable content) was something I always wanted to add but never got around to. Sadly the logic is pretty intertwined with text formatting stuff, it might not be a pleasant project to add this
Thanks for the reply. The project I worked on in May is over now, and I have zero time for open-source-contributions right now so I have to retract my offer to help here. I do want to share what I did in the end, maybe it's useful to someone:
I ended up using loguru
for stack-printing, along with some custom logic to print the state of objects and local variables of a few frames. This produces a pure text output except in a few places where I actually wanted html (mostly the expandable sections and pandas). Instead of putting the html directly in the text, I put only an identifier in the text, so the text without any html-elements could be converted to html with ansi2html
. After that, the identifiers are replaced by html again.
I can't share the code as it was closed source (and it is messy anyways), but I wanted to drop the idea that helped me do it with ansi2html that I also used to hack it in here to make the demo_stack_dump linked above:
Hello,
I am using a custom library to log loads of information in error-scenarios in a long-running computation. Today I discovered your library which is way more awesome than what I built.
However, there is one feature that I implemented in my code that I miss: The error-dumps are created as html. This makes it possible to (1) email them around, preserving colors (2) print variables in a short form but keep the 'full' version as expandable on a click (3) beatifully render objects that already define an html-representation (pandas dataframes)
Here is an example of what the script demo.py would output: (github doesnt let me upload as html but it is html)
demo_stack_dump.txt
If you are interested in having this feature I can code it up properly and we can maybe find a good way to expose it through the api in a backwards-compatible way.