alexmojaki / snoop

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

Discussion: visual design #1

Open alexmojaki opened 5 years ago

alexmojaki commented 5 years ago

The current look of snoop is the result of many small decisions and I really don't know if I made the right ones. What would you change about the appearance if you could? This could be about color, layout, the choice of words or special characters, and more. No detail is too small to post about here. Please also vote on proposals with reactions to help me see how popular they are.

alexmojaki commented 5 years ago

Here's a thought: what if each thread name/identifier in the columns (i.e. what shows after install(columns='thread thread_ident') had a unique color, making it easier to pick out the correct lines visually? E.g. suppose the name Thread-1 was always purple and Thread-2 was always green.

alexmojaki commented 5 years ago

Should I reverse the indentation when using pp.deep? For example this:

from snoop import pp

x = 1
y = 2
z = 3

assert 6 == pp.deep(lambda: x + y + z)

Currently outputs this:

12:21:10.98 LOG:
12:21:11.01 ............ x = 1
12:21:11.01 ............ y = 2
12:21:11.01 ........ x + y = 3
12:21:11.01 ........ z = 3
12:21:11.01 .... x + y + z = 6

Would it be better if I changed it to this?

12:17:40.91 LOG:
12:17:40.92 .... x = 1
12:17:40.93 .... y = 2
12:17:40.93 ........ x + y = 3
12:17:40.93 ........ z = 3
12:17:40.93 ............ x + y + z = 6

Thumbs up to change it, thumbs down to keep it the same.

sirex commented 5 years ago

On my terminal, time color is almost invisible, here is how it looks:

Ekrano nuotrauka iš 2019-09-03 16-48-14

It would be nice, if column colors would be taken from pygments theme if that is possible.

alexmojaki commented 5 years ago

Thanks @sirex. Getting colors right across all terminals and backgrounds is very tricky and has caused me quite a bit of trouble. I've created #14 to try tackling this. It should make columns the same color as comments as configured by pygments. How does that sound?

ivanhercaz commented 5 years ago

Hi @alexmojaki! In order to reply to your question about if you have to reverse the indentation of pp.deep, it makes more sense to me if you reverse it, I mean like the next example:


12:17:40.92 .... x = 1
12:17:40.93 .... y = 2
12:17:40.93 ........ x + y = 3
12:17:40.93 ........ z = 3
12:17:40.93 ............ x + y + z = 6```
martinsmid commented 5 years ago

Would it make sense to change the indent char from . to something else to express the nested evaluation rather than source indentation ? Or maybe just change to color if there is no proper char, or you don't want to use some unicode special.

alexmojaki commented 5 years ago

@martinsmid can you elaborate?

martinsmid commented 5 years ago

Maybe something like this

12:17:40.92 .... x = 1
12:17:40.93 .... y = 2
12:17:40.93 .... . . x + y = 3
12:17:40.93 .... . . z = 3
12:17:40.93 .... . . . .  x + y + z = 6

I didn't think about this thoroughly yet. And also I am not experienced with the current snoop's output in general.

Now when I look at the original output in your post, I would probably just differentiate the indent as in my example, without the reversal of the indent.

12:21:11.01 .... . . . . x = 1
12:21:11.01 .... . . . . y = 2
12:21:11.01 .... . . x + y = 3
12:21:11.01 .... . . z = 3
12:21:11.01 .... x + y + z = 6
alexmojaki commented 5 years ago

Why do you want to differentiate between the dots? Does anyone else think this would be helpful?

TejasAvinashShetty commented 4 years ago

Why do you want to differentiate between the dots? Does anyone else think this would be helpful?

Nope

KyleKing commented 4 years ago

For multi-line output, could the columns be printed only on the first LOG: line?

Example:

from pathlib import Path

import snoop

snooper = snoop.Config(columns='time,thread,thread_ident,file,full_file,function,function_qualname', out='tmp.log')

snooper.pp([*Path(__file__).parent.resolve().glob('*.*')])

Currently it might look like this:

06:28:24.23 MainThread 4534779328 tmp.py /Users/kyleking/Developer/Pull_Requests/Eel/tmp.py <module> <module> LOG:
06:28:24.25 MainThread 4534779328 tmp.py /Users/kyleking/Developer/Pull_Requests/Eel/tmp.py <module> <module> .... [*Path(__file__).parent.resolve().glob('*.*')] = [PosixPath('/Users/kyleking/Developer/Pull_Requests/Eel/.DS_Store'),
06:28:24.25 MainThread 4534779328 tmp.py /Users/kyleking/Developer/Pull_Requests/Eel/tmp.py <module> <module>                                                        PosixPath('/Users/kyleking/Developer/Pull_Requests/Eel/requirements.txt'),
06:28:24.25 MainThread 4534779328 tmp.py /Users/kyleking/Developer/Pull_Requests/Eel/tmp.py <module> <module>                                                        PosixPath('/Users/kyleking/Developer/Pull_Requests/Eel/.tox'),
06:28:24.25 MainThread 4534779328 tmp.py /Users/kyleking/Developer/Pull_Requests/Eel/tmp.py <module> <module>                                                        PosixPath('/Users/kyleking/Developer/Pull_Requests/Eel/README-developers.md'),
06:28:24.25 MainThread 4534779328 tmp.py /Users/kyleking/Developer/Pull_Requests/Eel/tmp.py <module> <module>                                                        PosixPath('/Users/kyleking/Developer/Pull_Requests/Eel/CHANGELOG.md'),
06:28:24.25 MainThread 4534779328 tmp.py /Users/kyleking/Developer/Pull_Requests/Eel/tmp.py <module> <module>                                                        PosixPath('/Users/kyleking/Developer/Pull_Requests/Eel/requirements-test.txt'),
06:28:24.25 MainThread 4534779328 tmp.py /Users/kyleking/Developer/Pull_Requests/Eel/tmp.py <module> <module>                                                        PosixPath('/Users/kyleking/Developer/Pull_Requests/Eel/tmp.py'),
06:28:24.25 MainThread 4534779328 tmp.py /Users/kyleking/Developer/Pull_Requests/Eel/tmp.py <module> <module>                                                        PosixPath('/Users/kyleking/Developer/Pull_Requests/Eel/MANIFEST.in'),
06:28:24.25 MainThread 4534779328 tmp.py /Users/kyleking/Developer/Pull_Requests/Eel/tmp.py <module> <module>                                                        PosixPath('/Users/kyleking/Developer/Pull_Requests/Eel/README.md'),
06:28:24.25 MainThread 4534779328 tmp.py /Users/kyleking/Developer/Pull_Requests/Eel/tmp.py <module> <module>                                                        PosixPath('/Users/kyleking/Developer/Pull_Requests/Eel/setup.py'),
06:28:24.25 MainThread 4534779328 tmp.py /Users/kyleking/Developer/Pull_Requests/Eel/tmp.py <module> <module>                                                        PosixPath('/Users/kyleking/Developer/Pull_Requests/Eel/.gitignore'),
06:28:24.25 MainThread 4534779328 tmp.py /Users/kyleking/Developer/Pull_Requests/Eel/tmp.py <module> <module>                                                        PosixPath('/Users/kyleking/Developer/Pull_Requests/Eel/Eel.egg-info'),
06:28:24.25 MainThread 4534779328 tmp.py /Users/kyleking/Developer/Pull_Requests/Eel/tmp.py <module> <module>                                                        PosixPath('/Users/kyleking/Developer/Pull_Requests/Eel/.github'),
06:28:24.25 MainThread 4534779328 tmp.py /Users/kyleking/Developer/Pull_Requests/Eel/tmp.py <module> <module>                                                        PosixPath('/Users/kyleking/Developer/Pull_Requests/Eel/tox.ini'),
06:28:24.25 MainThread 4534779328 tmp.py /Users/kyleking/Developer/Pull_Requests/Eel/tmp.py <module> <module>                                                        PosixPath('/Users/kyleking/Developer/Pull_Requests/Eel/requirements-meta.txt'),
06:28:24.25 MainThread 4534779328 tmp.py /Users/kyleking/Developer/Pull_Requests/Eel/tmp.py <module> <module>                                                        PosixPath('/Users/kyleking/Developer/Pull_Requests/Eel/.python-version'),
06:28:24.25 MainThread 4534779328 tmp.py /Users/kyleking/Developer/Pull_Requests/Eel/tmp.py <module> <module>                                                        PosixPath('/Users/kyleking/Developer/Pull_Requests/Eel/.git'),
06:28:24.25 MainThread 4534779328 tmp.py /Users/kyleking/Developer/Pull_Requests/Eel/tmp.py <module> <module>                                                        PosixPath('/Users/kyleking/Developer/Pull_Requests/Eel/.travis.yml')]

But i would find it easier to read like this

06:28:24.23 MainThread 4534779328 tmp.py /Users/kyleking/Developer/Pull_Requests/Eel/tmp.py <module> <module> LOG:
.... [*Path(__file__).parent.resolve().glob('*.*')] = [PosixPath('/Users/kyleking/Developer/Pull_Requests/Eel/.DS_Store'),
                                                       PosixPath('/Users/kyleking/Developer/Pull_Requests/Eel/requirements.txt'),
                                                       PosixPath('/Users/kyleking/Developer/Pull_Requests/Eel/.tox'),
                                                       PosixPath('/Users/kyleking/Developer/Pull_Requests/Eel/README-developers.md'),
                                                       PosixPath('/Users/kyleking/Developer/Pull_Requests/Eel/CHANGELOG.md'),
                                                       PosixPath('/Users/kyleking/Developer/Pull_Requests/Eel/requirements-test.txt'),
                                                       PosixPath('/Users/kyleking/Developer/Pull_Requests/Eel/tmp.py'),
                                                       PosixPath('/Users/kyleking/Developer/Pull_Requests/Eel/MANIFEST.in'),
                                                       PosixPath('/Users/kyleking/Developer/Pull_Requests/Eel/README.md'),
                                                       PosixPath('/Users/kyleking/Developer/Pull_Requests/Eel/setup.py'),
                                                       PosixPath('/Users/kyleking/Developer/Pull_Requests/Eel/.gitignore'),
                                                       PosixPath('/Users/kyleking/Developer/Pull_Requests/Eel/Eel.egg-info'),
                                                       PosixPath('/Users/kyleking/Developer/Pull_Requests/Eel/.github'),
                                                       PosixPath('/Users/kyleking/Developer/Pull_Requests/Eel/tox.ini'),
                                                       PosixPath('/Users/kyleking/Developer/Pull_Requests/Eel/requirements-meta.txt'),
                                                       PosixPath('/Users/kyleking/Developer/Pull_Requests/Eel/.python-version'),
                                                       PosixPath('/Users/kyleking/Developer/Pull_Requests/Eel/.git'),
                                                       PosixPath('/Users/kyleking/Developer/Pull_Requests/Eel/.travis.yml')]

Or maybe there is a happy medium:

06:28:24.23 MainThread 4534779328 tmp.py /Users/kyleking/Developer/Pull_Requests/Eel/tmp.py <module> <module> LOG:
06:28:24.25 .... [*Path(__file__).parent.resolve().glob('*.*')] = [PosixPath('/Users/kyleking/Developer/Pull_Requests/Eel/.DS_Store'),
06:28:24.25                                                        PosixPath('/Users/kyleking/Developer/Pull_Requests/Eel/requirements.txt'),
06:28:24.25                                                        PosixPath('/Users/kyleking/Developer/Pull_Requests/Eel/.tox'),
06:28:24.25                                                        PosixPath('/Users/kyleking/Developer/Pull_Requests/Eel/README-developers.md'),
06:28:24.25                                                        PosixPath('/Users/kyleking/Developer/Pull_Requests/Eel/CHANGELOG.md'),
06:28:24.25                                                        PosixPath('/Users/kyleking/Developer/Pull_Requests/Eel/requirements-test.txt'),
06:28:24.25                                                        PosixPath('/Users/kyleking/Developer/Pull_Requests/Eel/tmp.py'),
06:28:24.25                                                        PosixPath('/Users/kyleking/Developer/Pull_Requests/Eel/MANIFEST.in'),
06:28:24.25                                                        PosixPath('/Users/kyleking/Developer/Pull_Requests/Eel/README.md'),
06:28:24.25                                                        PosixPath('/Users/kyleking/Developer/Pull_Requests/Eel/setup.py'),
06:28:24.25                                                        PosixPath('/Users/kyleking/Developer/Pull_Requests/Eel/.gitignore'),
06:28:24.25                                                        PosixPath('/Users/kyleking/Developer/Pull_Requests/Eel/Eel.egg-info'),
06:28:24.25                                                        PosixPath('/Users/kyleking/Developer/Pull_Requests/Eel/.github'),
06:28:24.25                                                        PosixPath('/Users/kyleking/Developer/Pull_Requests/Eel/tox.ini'),
06:28:24.25                                                        PosixPath('/Users/kyleking/Developer/Pull_Requests/Eel/requirements-meta.txt'),
06:28:24.25                                                        PosixPath('/Users/kyleking/Developer/Pull_Requests/Eel/.python-version'),
06:28:24.25                                                        PosixPath('/Users/kyleking/Developer/Pull_Requests/Eel/.git'),
06:28:24.25                                                        PosixPath('/Users/kyleking/Developer/Pull_Requests/Eel/.travis.yml')]
alexmojaki commented 4 years ago

@KyleKing I don't like this idea. Having a consistent block of columns is:

KyleKing commented 4 years ago

Okay makes sense


On another note, could a column option be available for the line number?

from pathlib import Path

import snoop

snooper = snoop.Config(columns='time,file,line')

snooper.pp([*Path(__file__).parent.resolve().glob('*.*')])
06:28:24.23 tmp.py None LOG:
06:28:24.25 tmp.py 6  .... [*Path(__file__).parent.resolve().glob('*.*')] = [PosixPath('/Users/kyleking/Developer/Pull_Requests/Eel/.DS_Store'),
06:28:24.25 tmp.py 6                                                        PosixPath('/Users/kyleking/Developer/Pull_Requests/Eel/requirements.txt'),
06:28:24.25 tmp.py 6                                                        PosixPath('/Users/kyleking/Developer/Pull_Requests/Eel/.tox'),

(I'm not sure how the first LOG line would be handled, but put None for now)

alexmojaki commented 4 years ago

You can do this:

from pathlib import Path

import snoop

def line_column(event):
    return event.line_no

snooper = snoop.Config(columns=['time', 'file', line_column])

snooper.pp([*Path(__file__).parent.resolve().glob('*.*')])

It feels a bit weird to add this as a column since the line number is usually showing if you use @snoop and not just pp.

danr commented 3 years ago

For this program:

from snoop import pp

x = 1
y = 2
z = 3

assert 6 == pp.deep(lambda: x + y + z)

Why not output this?

12:21:10.98 LOG:
12:21:11.01 .... x = 1
12:21:11.01 ........ y = 2
12:21:11.01 .... x + y = 3
12:21:11.01 ............ z = 3
12:21:11.01 .... x + y + z = 6