diff options
author | Martin Braun <martin.braun@ettus.com> | 2018-01-15 15:07:12 -0800 |
---|---|---|
committer | Martin Braun <martin.braun@ettus.com> | 2018-02-08 22:18:14 +0100 |
commit | 44533fb035d4e9629d62f79a95ea9eb0487dcfef (patch) | |
tree | 75e799977912f51406089baa3743ba78b229f29c /mpm | |
parent | e6dc09470d506cfe4e74fc52f8a8ef21c16b9f2f (diff) | |
download | uhd-44533fb035d4e9629d62f79a95ea9eb0487dcfef.tar.gz uhd-44533fb035d4e9629d62f79a95ea9eb0487dcfef.tar.bz2 uhd-44533fb035d4e9629d62f79a95ea9eb0487dcfef.zip |
mpm: Use prefs API in logging module
This allows to set the default log level from the config file.
Diffstat (limited to 'mpm')
-rw-r--r-- | mpm/python/usrp_mpm/mpmlog.py | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/mpm/python/usrp_mpm/mpmlog.py b/mpm/python/usrp_mpm/mpmlog.py index 113d4bd06..494ee8f2f 100644 --- a/mpm/python/usrp_mpm/mpmlog.py +++ b/mpm/python/usrp_mpm/mpmlog.py @@ -27,9 +27,6 @@ RESET = str('\x1b[0m') # Additional log level TRACE = 1 -DEFAULT_LOG_LEVEL = INFO -DEFAULT_LOG_BUF_SIZE = 100 # In number of log records - class ColorStreamHandler(logging.StreamHandler): """ StreamHandler that prints colored output @@ -81,8 +78,9 @@ class MPMLogger(logging.getLoggerClass()): self.cpp_log_buf = lib.types.log_buf.make_singleton() except ImportError: pass + from usrp_mpm import prefs self.py_log_buf = collections.deque( - maxlen=kwargs.get('log_buf_size', DEFAULT_LOG_BUF_SIZE) + maxlen=prefs.get_prefs().getint('mpm', 'log_buf_size') ) def trace(self, *args, **kwargs): @@ -144,8 +142,10 @@ def get_main_logger( queue_handler = LossyQueueHandler(LOGGER.py_log_buf) LOGGER.addHandler(queue_handler) # Set default level: + from usrp_mpm import prefs + mpm_prefs = prefs.get_prefs() default_log_level = int(min( - DEFAULT_LOG_LEVEL - log_default_delta * 10, + mpm_prefs.get_log_level() - log_default_delta * 10, CRITICAL )) default_log_level = max(TRACE, default_log_level - (default_log_level % 10)) @@ -162,7 +162,7 @@ def get_main_logger( LOGGER.cpp_log_buf.set_notify_callback(log_from_cpp) # Flush errors stuck in the prefs module: log = LOGGER.getChild('prefs') - for err_key, err_msg in mpm_prefs['__ERRORS__'].items(): + for err_key, err_msg in mpm_prefs.get_log_errors(): log.error('%s: %s', err_key, err_msg) return LOGGER |