From c5f34a93b0911bbf3d386faa61128ef3507ca3d0 Mon Sep 17 00:00:00 2001 From: jackson Date: Tue, 21 May 2024 15:06:19 -0400 Subject: [PATCH] set debugging level to DEBUG conditionally --- histoqc/__main__.py | 2 +- histoqc/_pipeline.py | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/histoqc/__main__.py b/histoqc/__main__.py index 02363d8..1324cf2 100644 --- a/histoqc/__main__.py +++ b/histoqc/__main__.py @@ -105,7 +105,7 @@ def main(argv=None): # --- create output directory and move log -------------------------------- args.outdir = os.path.expanduser(args.outdir) os.makedirs(args.outdir, exist_ok=True) - move_logging_file_handler(logging.getLogger(), args.outdir) + move_logging_file_handler(logging.getLogger(), args.outdir, args.debug) if BatchedResultFile.results_in_path(args.outdir): if args.force: diff --git a/histoqc/_pipeline.py b/histoqc/_pipeline.py index 1e21ad4..2c61e6d 100644 --- a/histoqc/_pipeline.py +++ b/histoqc/_pipeline.py @@ -67,7 +67,7 @@ def setup_logging(*, capture_warnings, filter_warnings): logging.captureWarnings(capture_warnings) -def move_logging_file_handler(logger, destination): +def move_logging_file_handler(logger, destination, debug=False): """point the logging file handlers to the new destination Parameters @@ -94,7 +94,7 @@ def move_logging_file_handler(logger, destination): new_filename = shutil.move(handler.baseFilename, destination) new_handler = logging.FileHandler(new_filename, mode='a') - new_handler.setLevel(handler.level) + new_handler.setLevel(logging.DEBUG if debug else handler.level) new_handler.setFormatter(handler.formatter) logger.addHandler(new_handler)