From c2f20d744fce94f55d94e6d320f6258cb98224f4 Mon Sep 17 00:00:00 2001 From: Fede Raimondo Date: Thu, 5 Dec 2024 10:26:10 +0100 Subject: [PATCH] Add a logging handler if there are none --- tools/schemacode/src/bidsschematools/utils.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/tools/schemacode/src/bidsschematools/utils.py b/tools/schemacode/src/bidsschematools/utils.py index c518a88bb5..0aa6d71f45 100644 --- a/tools/schemacode/src/bidsschematools/utils.py +++ b/tools/schemacode/src/bidsschematools/utils.py @@ -34,6 +34,11 @@ def get_logger(name=None): # Basic settings for output, for now just basic set_logger_level(logger, os.environ.get("BIDS_SCHEMA_LOG_LEVEL", logging.INFO)) format="%(asctime)-15s [%(levelname)8s] %(message)s" + if len(logger.handlers) == 0: + # add a handler if there isn't one + ch = logging.StreamHandler() + logger.addHandler(ch) + # Set the formatter for the handlers for lh in logger.handlers: lh.setFormatter(logging.Formatter(format))