aboutsummaryrefslogtreecommitdiffstats
path: root/mpm
diff options
context:
space:
mode:
Diffstat (limited to 'mpm')
-rwxr-xr-xmpm/python/usrp_hwd.py19
-rw-r--r--mpm/python/usrp_mpm/mpmlog.py15
2 files changed, 30 insertions, 4 deletions
diff --git a/mpm/python/usrp_hwd.py b/mpm/python/usrp_hwd.py
index 90f865da0..4149ff40d 100755
--- a/mpm/python/usrp_hwd.py
+++ b/mpm/python/usrp_hwd.py
@@ -63,6 +63,20 @@ def setup_arg_parser():
"used as defaults for device initialization.",
default=None
)
+ parser.add_argument(
+ '-v',
+ '--verbose',
+ help="Increase verbosity level",
+ action="count",
+ default=0
+ )
+ parser.add_argument(
+ '-q',
+ '--quiet',
+ help="Decrease verbosity level",
+ action="count",
+ default=0
+ )
return parser
def parse_args():
@@ -100,7 +114,6 @@ def kill_time(sig, frame):
proc.join()
except BlockingSwitchOutError:
log.debug("Caught BlockingSwitchOutError for {}".format(str(proc)))
- pass
log.info("System exiting")
sys.exit(0)
@@ -111,8 +124,10 @@ def main():
Main process loop.
"""
- log = mpm.get_main_logger().getChild('main')
args = parse_args()
+ log = mpm.get_main_logger(
+ log_default_delta=args.verbose-args.quiet
+ ).getChild('main')
shared = SharedState()
# Create the periph_manager for this device
# This call will be forwarded to the device specific implementation
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