aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMartin Braun <martin.braun@ettus.com>2017-11-14 21:55:08 -0800
committerMartin Braun <martin.braun@ettus.com>2017-12-22 15:05:06 -0800
commitfa765de7db4ab0933578e986c967d6e8eea60170 (patch)
tree9863252bfddbf50264d6c643f6477f0e7f9d70d6
parentca55a983700437e5ca2f6e1517bc5b6670d14154 (diff)
downloaduhd-fa765de7db4ab0933578e986c967d6e8eea60170.tar.gz
uhd-fa765de7db4ab0933578e986c967d6e8eea60170.tar.bz2
uhd-fa765de7db4ab0933578e986c967d6e8eea60170.zip
mpm: Run C++ logger through central logging
Reviewed-By: Mark Meserve <mark.meserve@ni.com>
-rw-r--r--mpm/python/usrp_mpm/mpmlog.py16
1 files changed, 16 insertions, 0 deletions
diff --git a/mpm/python/usrp_mpm/mpmlog.py b/mpm/python/usrp_mpm/mpmlog.py
index af3018b32..94c23fc22 100644
--- a/mpm/python/usrp_mpm/mpmlog.py
+++ b/mpm/python/usrp_mpm/mpmlog.py
@@ -72,6 +72,12 @@ class MPMLogger(logging.getLoggerClass()):
"""
def __init__(self, *args, **kwargs):
logging.Logger.__init__(self, *args, **kwargs)
+ self.cpp_log_buf = None
+ try:
+ import usrp_mpm.libpyusrp_periphs as lib
+ self.cpp_log_buf = lib.types.log_buf.make_singleton()
+ except ImportError:
+ pass
def trace(self, *args, **kwargs):
""" Extends logging for super-high verbosity """
@@ -113,6 +119,16 @@ def get_main_logger(
))
default_log_level = max(1, default_log_level - (default_log_level % 10))
LOGGER.setLevel(default_log_level)
+ # Connect to C++ logging:
+ if LOGGER.cpp_log_buf is not None:
+ lib_logger = LOGGER.getChild('lib')
+ def log_from_cpp():
+ " Callback for logging from C++ "
+ log_level, component, message = LOGGER.cpp_log_buf.pop()
+ if log_level:
+ lib_logger.log(log_level, "[%s] %s",
+ component, message.strip())
+ LOGGER.cpp_log_buf.set_notify_callback(log_from_cpp)
return LOGGER
def get_logger(child_name):