3 ms·
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__)` an
by oblvious-earth 4y ago
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-logging-tutorial https://docs.python.org/3/howto/logging.html#advanced-loggin...
- funstuff007 4y agotrue 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