icecream
icecream copied to clipboard
Have ic() output class name as well
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
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.
Great! Could you please provide an example of how to make ic
use that instead than the default behavior?
No I'm suggesting how this feature could be added to the library.
@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!
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).