Tigge / openant

ANT and ANT-FS Python Library
MIT License
182 stars 85 forks source link

Do not print() within Modules #75

Closed daryltucker closed 1 year ago

daryltucker commented 2 years ago

Allow developers to control what is printed in their applications (and where) by only using a logger within module code.

Even after disabling loggers, I was getting DEBUG information printing to stdout. I tried a lot of things, and got pretty desperate...

loggers = [logging.getLogger(name) for name in logging.root.manager.loggerDict]
for logger in loggers:
    try:
        logger.removeHandler(sys.stderr)
    except Exception:
        pass
    logger.setLevel(0)
    logger.disabled = True
    logger.propagate = False

Then I found print statements in the module.


This uses the existing logger instead of print. There are also some small fixes to technically incorrect Exception statements.

tuna-f1sh commented 1 year ago

logging module now replaces use of print() within modules as part of https://github.com/Tigge/openant/pull/76