gruns / icecream

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

Doesn't print anything #121

Closed SmartManoj closed 2 years ago

SmartManoj commented 2 years ago

v2.1.2

Steps to reproduce: import faster_than_requests

Output:

Just traceback
Traceback (most recent call last):
  File "a.py", line 1, in <module>
    import faster_than_requests

Used monkey-patch:

ic2 = ic

def ic(*args):
    o = ic2(*args)
    print('!', *args)
    return o

New output:

! /home/ssh-key-2021-12-25/.local/lib/python3.8/site-packages/faster_than_requests/faster_than_requests.nim
! <ExtLib .local.lib.python3.8.site-packages.faster_than_requests.faster_than_requests>
! Compiling /home/ssh-key-2021-12-25/.local/lib/python3.8/site-packages/faster_than_requests/faster_than_requests.nim
! Compiling /home/ssh-key-2021-12-25/.local/lib/python3.8/site-packages/faster_than_requests/faster_than_requests.nim
! /tmp/tmpqzmrodh8/faster_than_requests.nim
! ['nimble', 'c', '--accept', '--skipUserCfg', '--app:lib', '--backend:c', '--warning[ProveInit]:off', '--threads:on', '--cc:gcc', 'faster_than_requests.nim']
Traceback (most recent call last):
File "a.py", line 1, in <module>
    import faster_than_requests
    ....
alexmojaki commented 2 years ago

I don't really understand what you're saying, but I'm guessing the problem is that ic is printing to stderr and for some reason you can only see stdout.

SmartManoj commented 2 years ago

oops It's disabled in the package with the var NIMPORTER_INSTRUMENT. Sorry

dineshbvadhia commented 2 years ago

@alexmojaki

Re: "I don't really understand what you're saying, but I'm guessing the problem is that ic is printing to stderr and for some reason you can only see stdout."

This maybe the problem I'm having. What is the solution? Thanks

alexmojaki commented 2 years ago

ic.configureOutput(outputFunction=print)

dineshbvadhia commented 2 years ago

For use in multiple files, is the sequence in the root source?:

from icecream import ic
ic.configureOutput(outputFunction=print)
from icecream import install
install()
alexmojaki commented 2 years ago

Yes, that looks fine. You can merge the two imports into one line.