Allow overriding the root logger name

Handy if other dependent projects want to use the logging system but
also want to slap their own root "branding" onto the record prefix.
log_task_context
Tyler Goodlet 2019-12-20 16:37:17 -05:00
parent 79c152fe38
commit e2c9477122
1 changed files with 5 additions and 4 deletions

View File

@ -49,11 +49,12 @@ BOLD_PALETTE = {
def get_logger(
name: str = None
name: str = None,
_root_name: str = _proj_name,
) -> logging.LoggerAdapter:
'''Return the package log or a sub-log for `name` if provided.
'''
log = rlog = logging.getLogger(_proj_name)
log = rlog = logging.getLogger(_root_name)
if name and name != _proj_name:
log = rlog.getChild(name)
log.level = rlog.level
@ -73,13 +74,13 @@ def get_logger(
def get_console_log(
level: str = None,
name: str = None
**kwargs,
) -> logging.LoggerAdapter:
'''Get the package logger and enable a handler which writes to stderr.
Yeah yeah, i know we can use ``DictConfig``. You do it.
'''
log = get_logger(name) # our root logger
log = get_logger(**kwargs) # our root logger
logger = log.logger
if not level: