From: Leandro Lucarella Date: Thu, 19 Jun 2008 01:17:42 +0000 (-0300) Subject: Hack to overcome Python's bug 3136 in logging system (refs #7). X-Git-Url: https://git.llucax.com/software/pymin.git/commitdiff_plain/9087aa61851dfea2c4c6f81c54d295aabc9b2849?ds=inline Hack to overcome Python's bug 3136 in logging system (refs #7). logging.config.fileConfig() disables all existing loggers that are not configured using the config file. This hack re-enable the loggers so everything works as expected even when you don't specify *all* the loggers in the configuration files (and child loggers really inherits their parent configuration). --- diff --git a/pymind b/pymind index da7b218..fa4fa36 100755 --- a/pymind +++ b/pymind @@ -133,6 +133,12 @@ def build_root(config, args, services): def setup_logging(config_files): + # XXX: this is a hack for re-enabling loggers not configured via + # fileConfig(). This function disable all existing loggers that + # has no configuration specified in the config file, so we have + # to re-enable the by hand. + # See Python bug 3136: http://bugs.python.org/issue3136 + existing = logging.root.manager.loggerDict.keys() loaded_files = 0 for f in config_files: try: @@ -145,6 +151,9 @@ def setup_logging(config_files): loaded_files += 1 if not loaded_files: log.warning('no log config file loaded') + # XXX: finish the hack commented above + for log in existing: + logging.root.manager.loggerDict[log].disabled = 0 def main():