From 69e2e22f58c99b927e44ea80b0d3b16f1c06e809 Mon Sep 17 00:00:00 2001 From: Oliver Smith Date: Wed, 13 Feb 2019 09:55:26 +0100 Subject: [PATCH] init: fix missing errors if logs didn't initialize (!1755) Set the log level to DEBUG if args (and therefore logging) failed to initialize. This causes the default logging handler to be used, and everything that gets written to the log (error message and trace!) will get printed to stdout instead of not being printed anywhere at all. This can be tested by removing x86_64 from the mapping in pmb.parse.arch.alpine_native() (assuming the host is x86_64). Without this patch, no meaningful error appears. With the patch, the real error message, and a stack trace gets printed. --- pmb/__init__.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/pmb/__init__.py b/pmb/__init__.py index 00874ec3..3019285b 100644 --- a/pmb/__init__.py +++ b/pmb/__init__.py @@ -71,6 +71,10 @@ def main(): logging.info("Done") except Exception as e: + # Dump log to stdout when args (and therefore logging) init failed + if not args: + logging.getLogger().setLevel(logging.DEBUG) + logging.info("ERROR: " + str(e)) logging.info("See also: ") logging.debug(traceback.format_exc())