[Checkins] SVN: z3c.recipe.eggbasket/trunk/z3c/recipe/eggbasket/utils.py Remove additional logger handlers to avoid duplicate lines in output.
Uli Fouquet
uli at gnufix.de
Thu Feb 5 11:35:09 EST 2009
Log message for revision 96141:
Remove additional logger handlers to avoid duplicate lines in output.
Changed:
U z3c.recipe.eggbasket/trunk/z3c/recipe/eggbasket/utils.py
-=-
Modified: z3c.recipe.eggbasket/trunk/z3c/recipe/eggbasket/utils.py
===================================================================
--- z3c.recipe.eggbasket/trunk/z3c/recipe/eggbasket/utils.py 2009-02-05 16:32:35 UTC (rev 96140)
+++ z3c.recipe.eggbasket/trunk/z3c/recipe/eggbasket/utils.py 2009-02-05 16:35:09 UTC (rev 96141)
@@ -7,11 +7,29 @@
import tempfile
import urllib
+def remove_additional_root_logger_handlers():
+ """Remove additional root logger handlers.
+
+ Under certain circumstances it might happen, that multiple
+ handlers in the root logger are installed. This leads to duplicate
+ lines in output we want to avoid. Therefore we remove additional
+ handlers.
+ """
+ root_logger = logging.getLogger()
+ if len(root_logger.handlers) > 1:
+ for handler in root_logger.handlers[1:]:
+ if not isinstance(handler, logging.StreamHandler):
+ continue
+ root_logger.removeHandler(handler)
+ break
+ return
+
+remove_additional_root_logger_handlers() # See function docstring
# XXX We may want to add command line argument handling.
logging.basicConfig(level=logging.INFO,
format='%(levelname)-5s %(name)-12s %(message)s')
-log = logging.getLogger('basket')
+log = logging.getLogger('eggbasket')
def install_distributions(distributions, target_dir, links=[],
use_empty_index=False):
More information about the Checkins
mailing list