Skip to content

Commit

Permalink
Add a logging handler if there are none
Browse files Browse the repository at this point in the history
  • Loading branch information
fraimondo committed Dec 5, 2024
1 parent e6a8a40 commit c2f20d7
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions tools/schemacode/src/bidsschematools/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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))

Expand Down

0 comments on commit c2f20d7

Please sign in to comment.