summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichał Górny <mgorny@gentoo.org>2023-08-14 07:00:35 +0200
committerMichał Górny <mgorny@gentoo.org>2023-08-14 07:04:45 +0200
commit883745fbae6a3455ba6cfd4966757107f609a7eb (patch)
treeef2a4c692cbd84cd6cf9d5369e986c12768a91ad
parent82bc817f9dd96c3bac0bb22e8759b4f2fc992869 (diff)
downloadgemato-883745fbae6a3455ba6cfd4966757107f609a7eb.tar.gz
cli: Allow enabling debug via GEMATO_DEBUG envvar
Support using GEMATO_DEBUG envvar to override the log level and force DEBUG. This is mostly meant to handle calling gemato executable via scripts where users can't trivially pass `--debug`. When gemato is used via the Python API, the caller needs to configure the logger. Something akin to the following is recommended: logging.basicConfig() if os.environ.get("GEMATO_DEBUG"): logging.getLogger("gemato").setLevel(logging.DEBUG) plus passing `debug=True` to `OpenPGPEnvironment` constructors. CloseS: https://github.com/projg2/gemato/issues/7 Signed-off-by: Michał Górny <mgorny@gentoo.org>
-rw-r--r--gemato/cli.py4
1 files changed, 4 insertions, 0 deletions
diff --git a/gemato/cli.py b/gemato/cli.py
index 9c5c6cd..36c16fb 100644
--- a/gemato/cli.py
+++ b/gemato/cli.py
@@ -75,6 +75,10 @@ class GematoCommand:
Process command-line arguments @args. @argp is the argparse
instance provided for error reporting.
"""
+ # allow an easy override for users when gemato is called
+ # via scripts
+ if os.environ.get("GEMATO_DEBUG"):
+ args.log_level = logging.DEBUG
logging.getLogger().setLevel(args.log_level)
def __call__(self):