Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[REQUEST] Print out variable names (along with content) for console.log() #3358

Open
StefanHeng opened this issue May 12, 2024 · 1 comment

Comments

@StefanHeng
Copy link

Currently an icecream user - Came across this package - Love it!

One thing I like about icecream is that it's able to print out the name of the variable I'm logging. This makes debugging easier.

I've attached a screenshot comparing the debugging/logging of the same variable(s) below:

Screenshot 2024-05-12 at 2 15 13 AM

This is produced by:

            from icecream import ic
            from rich.console import Console
            console = Console()

            test_data = [{"jsonrpc": "2.0", "method": "sum", "params": [None, 1, 2, 4, False, True], "id": "1", },
                {"jsonrpc": "2.0", "method": "notify_hello", "params": [7]},
                {"jsonrpc": "2.0", "method": "subtract", "params": [42, 23], "id": "2"}, ]

            console.log(test_data)
            ic(test_data)

            txt, num = 'hello world', 42
            console.log(txt, num)
            ic(txt, num)

Note the text_data, txt, num are also printed.

I like that rich provides better styling - but I wish the variable names gets printed too. This will make more convenient debugging - as I don't have to type the variable name again.

Correct me if I'm wrong, I don't think this feature is currently supported.

Hopefully this feature can be easily implemented given that rich already have access to relevant variable names via log_locals (example below):
Screenshot 2024-05-12 at 2 18 21 AM

Copy link

Thank you for your issue. Give us a little time to review it.

PS. You might want to check the FAQ if you haven't done so already.

This is an automated reply, generated by FAQtory

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant