There are four common use cases for using logging.getLogger() to name our Loggers. We often pick names to parallel our application's architecture, as described in the following examples:
- Module names: We might have a module global Logger instance for modules that contain a large number of small functions or classes for which a large number of objects are created. When we extend tuple, for example, we don't want a reference to Logger in each instance. We'll often do this globally, and usually close to the front of the module, as follows:
import logging
logger = logging.getLogger(__name__)
- Object instances: This was shown previously, when we created Logger in the __init__() method. This Logger will be unique to the instance; ...