gruns / icecream

🍦 Never use print() to debug again.
MIT License
9.22k stars 187 forks source link

having ic() output class name #120

Open Loriasun opened 2 years ago

Loriasun commented 2 years ago

ic() output class name

Modified parentFunction in _getContext so that icecream prints class name for the method as well.

salabim commented 2 years ago

With the pull request, this program

from icecream import ic
ic.configureOutput(includeContext=True)

def a():
    def hello(val):
        ic(val)
    hello("world")
a()

results in

ic| test context icecream.py:6 in a.<locals>.hello()- val: 'world'

Therefore, I think it would be better to use

        parentFunction = executing.Source.executing(callFrame).code_qualname().replace(".<locals>.",".")
Loriasun commented 2 years ago

@salabim Thank you for your suggestion!

alexmojaki commented 2 years ago

I agree with @salabim's suggestion, I think a.hello is better than a.<locals>.hello for this purpose.

@Loriasun did you run the tests with this PR? I suspect many of them now fail and need updating.

We really need to have functioning CI again. I don't think #98 is going to happen, so it would be really helpful to set up GitHub actions to replace Travis.