findmissing: getopen: add debug option
Add debug option (-d, --debug) to enable debug logs.
Note: Python's logging default writes logs to stderr. Thus, the patch
doesn't break such `./getopen.py -c -d | tee -a conflicts` usage if any.
BUG=none
TEST=./getopen.py -c -d
Change-Id: I086d897adb69d22fc09e01694a3d52ca923c5d82
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/dev-util/+/3463399
Tested-by: Tzung-Bi Shih <tzungbi@chromium.org>
Reviewed-by: Guenter Roeck <groeck@chromium.org>
Commit-Queue: Tzung-Bi Shih <tzungbi@chromium.org>
diff --git a/contrib/findmissing/util.py b/contrib/findmissing/util.py
index a855290..1c01d00 100755
--- a/contrib/findmissing/util.py
+++ b/contrib/findmissing/util.py
@@ -59,7 +59,7 @@
"""Decorator for performing environment related checks."""
def wrap_preliminary_check(f):
"""Inner function that wraps method with preliminary check."""
- def wrapped_preliminary_check(*args):
+ def wrapped_preliminary_check(*args, **kwargs):
"""Sanity checks on state of environment before executing decorated function."""
if is_gce:
# Ensures we have service account credentials to connect to cloudsql (GCP)
@@ -73,12 +73,15 @@
if is_gce:
level = logging.INFO
else:
- level = logging.WARNING
+ if kwargs.get('debug'):
+ level = logging.DEBUG
+ else:
+ level = logging.WARNING
logging.basicConfig(format='%(asctime)s %(levelname)s: %(message)s', level=level,
datefmt='%Y-%m-%d %H:%M:%S')
- f(*args)
+ f(*args, **kwargs)
return wrapped_preliminary_check
return wrap_preliminary_check