Add convenience methods for all log levels

kivy_mainline_and_py3.8
Tyler Goodlet 2018-02-22 18:44:00 -05:00
parent ff437ce9e1
commit 4b59b87f98
1 changed files with 8 additions and 4 deletions

View File

@ -1,6 +1,7 @@
"""
Log like a forester!
"""
from functools import partial
import sys
import logging
import json
@ -51,6 +52,13 @@ def get_logger(name: str = None) -> logging.Logger:
if name and name != _proj_name:
log = rlog.getChild(name)
log.level = rlog.level
# additional levels
for name, val in LEVELS.items():
logging.addLevelName(val, name)
# ex. create ``log.trace()``
setattr(log, name.lower(), partial(log.log, val))
return log
@ -70,10 +78,6 @@ def get_console_log(level: str = None, name: str = None) -> logging.Logger:
):
handler = logging.StreamHandler()
# additional levels
for name, val in LEVELS.items():
logging.addLevelName(val, name)
formatter = colorlog.ColoredFormatter(
LOG_FORMAT,
datefmt=DATE_FORMAT,