Re:Logging in Python like a pro
by thechao on Friday July 01, 2022 @05:17PM
(#31953062)
None of which work reliably across multiple modules all fighting for control of the logger. Reliable is the key term, here.
[ Parent
| on HN ]
Re:Logging in Python like a pro
by oblvious-earth on Friday July 01, 2022 @08:26PM
(#31954775)
Don't write code where every module tries to make a root logger or set the logger config then.
Each module should use `logger = logging.getLogger(__name__)` and the logger config can set in one place, conventionally in the `__main__` script.
https://docs.python.org/3/howto/logging.html#advanced-loggin...
Re:Logging in Python like a pro
by funstuff007 on Friday July 01, 2022 @10:00PM
(#31955373)
true that. but I've never figured out a good way to do this and have a single test runner module log when invoked directly: python3 test_foo.py and indirectly python3 -m unittest test_foo