summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOlivier Gayot <olivier.gayot@sigexec.com>2021-01-04 19:12:16 +0100
committerOlivier Gayot <olivier.gayot@sigexec.com>2021-01-04 19:12:16 +0100
commit49233bf6ee28004314ca36afde9206eb5bc05efb (patch)
treecaa53e8263ff8cad904b836e04427de1f1503d34
parentf78c88b0a056cf5776f269673d65cf7f431937e5 (diff)
Add logging level option
Signed-off-by: Olivier Gayot <olivier.gayot@sigexec.com>
-rwxr-xr-xmonitor-menu.py15
1 files 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 <profile>
+ monitor-menu.py [options]
+ monitor-menu.py [options] <profile>
+
+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 '<profile>' in args and args['<profile>'] is not None:
menu.run(int(args['<profile>']))