
commit 5d200b1cdbebcd60cadf6455a9b1baf1d9431fb3 Author: Damian Johnson <atagar@torproject.org> Date: Sat Nov 12 16:19:34 2011 -0800 Avoid adding duplicate null logging handlers Checking if logging already has a handler before adding a NullHandler, to avoid having _every_ import trigger an extra no-op handler. --- stem/util/__init__.py | 5 ++++- 1 files changed, 4 insertions(+), 1 deletions(-) diff --git a/stem/util/__init__.py b/stem/util/__init__.py index 0391293..14692fe 100644 --- a/stem/util/__init__.py +++ b/stem/util/__init__.py @@ -11,7 +11,10 @@ import logging class NullHandler(logging.Handler): def emit(self, record): pass -logging.getLogger("stem").addHandler(NullHandler()) +stem_logger = logging.getLogger("stem") + +if not stem_logger.handlers: + stem_logger.addHandler(NullHandler()) __all__ = ["conf", "enum", "log", "proc", "system", "term"]