Logging ancestors ignored if config changes?
andrew at acooke.org
Sat Apr 26 08:21:06 EDT 2008
One way to handle this is to make creation of module-level Loggers
lazy, and make sure that logging initialisation occurs before any
other logging is actually used (which is not so hard - just init log
at the start of the application).
Of course, there's a performance hit...
def __init__(self, name):
self._name = name
self._lazy = None
def __getattr__(self, key):
if not self._lazy:
self._lazy = logging.getLogger(self._name)
return getattr(self._lazy, key)
and then, in some module:
from acooke.util.log import Log
log = Log(__name__)
log.debug("this works as expected")
More information about the Python-list