ionelmc / python-hunter

Hunter is a flexible code tracing toolkit.
https://python-hunter.readthedocs.io/
BSD 2-Clause "Simplified" License
796 stars 46 forks source link

hints for vim users #41

Closed ctrngk closed 4 years ago

ctrngk commented 6 years ago

To save output to hunter.log

PYTHONHUNTER='......' python3 script.py &> hunter.log

If you are a vim user, you might want to fold hunter.log by syntax "=>" and "<=" in the 3rd column of output. I have written simple vimscript to do this. Simply append the Hunter function to ~/.vimrc

usage: :call Hunter()

Unfortunately the output file is still plain without any color. My hands are tied. Sorry.

ionelmc commented 6 years ago

Try adding an action=CallPrinter(force_colors=True). The defaults are "no tty = no colors".

ctrngk commented 6 years ago

I do not understand. I redirect to the plain txt file and the color info will be removed. It is not HTML. Do you have a way saving the log file which contains the color info?

ionelmc commented 6 years ago

Because the output redirection stdout won't have a tty attached thus the tty detection fails. Normally people don't want ansi codes in log files (don't cite me on that tho 😁).

So if you insist in having colored output you use force_colors=True.

It's like grep output - add another | cat and match highlighting is usually lost.

ctrngk commented 6 years ago

I just color the log file in vim, just for easy reading.

2018-06-07_21-20-55-2