Type igore `colorlog`

type_annotations
Tyler Goodlet 2018-08-26 13:12:59 -04:00
parent 11cbf9ea55
commit 18c55e2b5f
1 changed files with 12 additions and 18 deletions

View File

@ -4,7 +4,7 @@ Log like a forester!
from functools import partial from functools import partial
import sys import sys
import logging import logging
import colorlog import colorlog # type: ignore
_proj_name = 'tractor' _proj_name = 'tractor'
_default_loglevel = None _default_loglevel = None
@ -69,16 +69,10 @@ def get_console_log(level: str = None, name: str = None) -> logging.Logger:
log = get_logger(name) # our root logger log = get_logger(name) # our root logger
if not level: if not level:
return return log
log.setLevel(level.upper() if not isinstance(level, int) else level) log.setLevel(level.upper() if not isinstance(level, int) else level)
if not any(
handler.stream == sys.stderr for handler in log.handlers
if getattr(handler, 'stream', None)
):
handler = logging.StreamHandler() handler = logging.StreamHandler()
formatter = colorlog.ColoredFormatter( formatter = colorlog.ColoredFormatter(
LOG_FORMAT, LOG_FORMAT,
datefmt=DATE_FORMAT, datefmt=DATE_FORMAT,