From 49233bf6ee28004314ca36afde9206eb5bc05efb Mon Sep 17 00:00:00 2001 From: Olivier Gayot Date: Mon, 4 Jan 2021 19:12:16 +0100 Subject: Add logging level option Signed-off-by: Olivier Gayot --- monitor-menu.py | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/monitor-menu.py b/monitor-menu.py index 710eab7..5c4ee3a 100755 --- a/monitor-menu.py +++ b/monitor-menu.py @@ -3,8 +3,11 @@ ''' monitor-menu.py Usage: - monitor-menu.py - monitor-menu.py + monitor-menu.py [options] + monitor-menu.py [options] + +Options: + --loglevel=LOGLEVEL Set the log level [default: info] ''' from os.path import expanduser @@ -12,6 +15,7 @@ from os.path import expanduser import dialog import docopt import json +import logging import subprocess d = dialog.Dialog() @@ -52,7 +56,9 @@ class MonitorMenu(): if monitor.get('background') is not None: feh_cmd.append(monitor['background']); + logging.debug("Executing: %s", xrandr_cmd) subprocess.run(xrandr_cmd) + logging.debug("Executing: %s", feh_cmd) subprocess.run(feh_cmd) @@ -61,6 +67,11 @@ def main(argv=None): menu = MonitorMenu() + numeric_level = getattr(logging, args["--loglevel"].upper(), None) + if not isinstance(numeric_level, int): + raise ValueError(f"invalid log level: {args['--loglevel']}") + logging.basicConfig(level=numeric_level) + try: if '' in args and args[''] is not None: menu.run(int(args[''])) -- cgit v1.2.3