I have a python module of the following structure
|- src
|- a
|- aa
|- x.py
|- y.py
|- ab
|- xx.py
|- b
|- ba
|- xxx.py
In the .py files, I have loggings like
logging.INFO("A")
logging.DEBUG("B")
I'm thinking to add a global control of the loggings for the whole module. I would like to set up a global logging level, say .setLevel(logging.INFO). Where should I do this? I have tried to put an __init__.py file in the src folder setting the logging level, but it seems to have no effect when I import functions from the .py files.
I'm wondering
- what is a good way to do this? The level should work when someone uses for example
from a.aa.x import A. - When I use
logger = logging.getLogger()in each.pyfile, are thelogger's all the same? - What's the benefit of using different loggers (say
logger = logging.getLogger(".a")andlogger = logging.getLogger(".b")in different.pyfiles)?