From 883745fbae6a3455ba6cfd4966757107f609a7eb Mon Sep 17 00:00:00 2001 From: Michał Górny Date: Mon, 14 Aug 2023 07:00:35 +0200 Subject: cli: Allow enabling debug via GEMATO_DEBUG envvar MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 --- gemato/cli.py | 4 ++++ 1 file changed, 4 insertions(+) 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): -- cgit v1.2.3