icecream icon indicating copy to clipboard operation
icecream copied to clipboard

Have ic() output class name as well

Open leotrs opened this issue 2 years ago • 5 comments

The following

class MyClass:
    def method(self):
        ic()
		
MyClass().method()

prints something along the lines of ic| test.py:3 in method() at 10:00:24.509. Is there a way to include the class name and get this instead? ic| test.py:3 in MyClass.method() at 10:00:24.509

leotrs avatar Mar 31 '22 08:03 leotrs

Yes. In this code:

https://github.com/gruns/icecream/blob/58fb2f454e7b0c7d00946f5cd885bb9a933c1e69/icecream/icecream.py#L329-L335

Using https://github.com/alexmojaki/executing#getting-the-qualname-of-the-current-function to get the qualname for parentFunction should work.

alexmojaki avatar Mar 31 '22 10:03 alexmojaki

Great! Could you please provide an example of how to make ic use that instead than the default behavior?

leotrs avatar Mar 31 '22 11:03 leotrs

No I'm suggesting how this feature could be added to the library.

alexmojaki avatar Mar 31 '22 11:03 alexmojaki

@alexmojaki Hi there! I am new to ice cream and GitHub but I would love to work on this issue as my first issue! Would you like to offer any suggestions! Thank you!

Loriasun avatar Apr 11 '22 18:04 Loriasun

I think the above comment is sufficient. Start by making sure you understand the existing _getContext code, and then how to get the qualname from executing in isolation (i.e. separately from icecream).

alexmojaki avatar Apr 11 '22 18:04 alexmojaki