diff options
author | Martin Braun <martin.braun@ettus.com> | 2017-11-14 22:27:14 -0800 |
---|---|---|
committer | Martin Braun <martin.braun@ettus.com> | 2017-12-22 15:05:05 -0800 |
commit | eccd185efb6b250cd6aa1f3f96b4c43d24cf4eb0 (patch) | |
tree | 6bd813a916845692abab494c6169d8d28fa89948 /mpm/python/usrp_mpm | |
parent | 4ca0e123a37e2a4cef44a142ebee02626297e9fe (diff) | |
download | uhd-eccd185efb6b250cd6aa1f3f96b4c43d24cf4eb0.tar.gz uhd-eccd185efb6b250cd6aa1f3f96b4c43d24cf4eb0.tar.bz2 uhd-eccd185efb6b250cd6aa1f3f96b4c43d24cf4eb0.zip |
mpm: Add configurable log levels
Diffstat (limited to 'mpm/python/usrp_mpm')
-rw-r--r-- | mpm/python/usrp_mpm/mpmlog.py | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/mpm/python/usrp_mpm/mpmlog.py b/mpm/python/usrp_mpm/mpmlog.py index d3be67550..af3018b32 100644 --- a/mpm/python/usrp_mpm/mpmlog.py +++ b/mpm/python/usrp_mpm/mpmlog.py @@ -36,6 +36,8 @@ RESET = str('\x1b[0m') # Additional log level TRACE = 1 +DEFAULT_LOG_LEVEL = TRACE + class ColorStreamHandler(logging.StreamHandler): """ StreamHandler that prints colored output @@ -77,7 +79,12 @@ class MPMLogger(logging.getLoggerClass()): LOGGER = None # Logger singleton -def get_main_logger(use_console=True, use_journal=False, console_color=True): +def get_main_logger( + use_console=True, + use_journal=False, + console_color=True, + log_default_delta=0 + ): """ Returns the top-level logger object. This is the only API call from this file that should be used outside. @@ -100,7 +107,11 @@ def get_main_logger(use_console=True, use_journal=False, console_color=True): journal_handler.setFormatter(journal_formatter) LOGGER.addHandler(journal_handler) # Set default level: - default_log_level = TRACE + default_log_level = int(min( + DEFAULT_LOG_LEVEL - log_default_delta * 10, + CRITICAL + )) + default_log_level = max(1, default_log_level - (default_log_level % 10)) LOGGER.setLevel(default_log_level) return LOGGER |