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,25 +69,19 @@ 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)
handler = logging.StreamHandler()
if not any( formatter = colorlog.ColoredFormatter(
handler.stream == sys.stderr for handler in log.handlers LOG_FORMAT,
if getattr(handler, 'stream', None) datefmt=DATE_FORMAT,
): log_colors=STD_PALETTE,
handler = logging.StreamHandler() secondary_log_colors=BOLD_PALETTE,
style='{',
formatter = colorlog.ColoredFormatter( )
LOG_FORMAT, handler.setFormatter(formatter)
datefmt=DATE_FORMAT, log.addHandler(handler)
log_colors=STD_PALETTE,
secondary_log_colors=BOLD_PALETTE,
style='{',
)
handler.setFormatter(formatter)
log.addHandler(handler)
return log return log