From e2c9477122d78dc58e40f40829d9d493b3693360 Mon Sep 17 00:00:00 2001 From: Tyler Goodlet Date: Fri, 20 Dec 2019 16:37:17 -0500 Subject: [PATCH] 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. --- tractor/log.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/tractor/log.py b/tractor/log.py index abe5a72..2f04c7b 100644 --- a/tractor/log.py +++ b/tractor/log.py @@ -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: