fixup logging some more

This commit is contained in:
Job Evers-Meltzer 2016-08-11 05:37:45 +00:00
parent c7430f4ae9
commit f4ef92e653
2 changed files with 4 additions and 6 deletions

View file

@ -1,8 +1,2 @@
import logging
log = logging.getLogger(__name__)
logging.getLogger(__name__).addHandler(logging.NullHandler())
log.setLevel(logging.INFO)
__version__ = "0.3.17"
version = tuple(__version__.split('.'))

View file

@ -55,6 +55,10 @@ def _log_decorator(fn):
def helper(*args, **kwargs):
log = kwargs.pop('log', logging.getLogger())
level = kwargs.pop('level', logging.INFO)
if not isinstance(level, int):
# despite the name, getLevelName returns
# the numeric level when passed a text level
level = logging.getLevelName(level)
handler = fn(*args, **kwargs)
if handler.name:
remove_handlers(log, handler.name)