alexmojaki / snoop

A powerful set of Python debugging tools, based on PySnooper
MIT License
1.28k stars 35 forks source link

broken color in vim #29

Closed goodluck110706112 closed 3 years ago

goodluck110706112 commented 3 years ago

I'm very happy that I found snoop, a very useful debug tool for python! But I found a problem about color, code:

` # torchsnooper.register_snoop()

snoop.install(out='/transformer_scst/snoop.log', color='vim')
@snoop()
def myfunc(mask, x):
    model = torch.nn.Linear(10, 2)
    logits = mask + x
    y_pred = model(logits)
    return y_pred

mask = torch.randn((10000, 10))
source = torch.randn((10000, 10))
y = myfunc(mask, source)`

But when I see log file use cat commant, the color is normal: image

but when I use vim ,the color is abnormal: image

How can I solve this problem? Thank you!

alexmojaki commented 3 years ago

This is normal. Displaying color in the terminal is implemented by special characters called ANSI escape codes. vim is showing you those characters. If you search for "vim color codes" there is information on how to deal with this, such as https://unix.stackexchange.com/questions/7695/how-to-make-vim-display-colors-as-indicated-by-color-codes