Skip to content

Commit

Permalink
Configure only the bst logger instead of the root logger
Browse files Browse the repository at this point in the history
  • Loading branch information
fraimondo committed Dec 5, 2024
1 parent d60531a commit e6a8a40
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 11 deletions.
3 changes: 0 additions & 3 deletions tools/schemacode/src/bidsschematools/render/tables.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,6 @@
from bidsschematools.utils import get_logger, set_logger_level

lgr = get_logger()
# Basic settings for output, for now just basic
set_logger_level(lgr, os.environ.get("BIDS_SCHEMA_LOG_LEVEL", logging.INFO))
logging.basicConfig(format="%(asctime)-15s [%(levelname)8s] %(message)s")

# Remember to add extension (.html or .md) to the paths when using them.
ENTITIES_PATH = "SPEC_ROOT/appendices/entities"
Expand Down
3 changes: 0 additions & 3 deletions tools/schemacode/src/bidsschematools/render/text.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,6 @@
from bidsschematools.utils import get_logger, set_logger_level

lgr = get_logger()
# Basic settings for output, for now just basic
set_logger_level(lgr, os.environ.get("BIDS_SCHEMA_LOG_LEVEL", logging.INFO))
logging.basicConfig(format="%(asctime)-15s [%(levelname)8s] %(message)s")

# Remember to add extension (.html or .md) to the paths when using them.
ENTITIES_PATH = "SPEC_ROOT/appendices/entities"
Expand Down
4 changes: 0 additions & 4 deletions tools/schemacode/src/bidsschematools/schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,6 @@
from .types import Namespace

lgr = utils.get_logger()
# Basic settings for output, for now just basic
utils.set_logger_level(lgr, os.environ.get("BIDS_SCHEMA_LOG_LEVEL", logging.INFO))
logging.basicConfig(format="%(asctime)-15s [%(levelname)8s] %(message)s")


class BIDSSchemaError(Exception):
"""Errors indicating invalid values in the schema itself"""
Expand Down
11 changes: 10 additions & 1 deletion tools/schemacode/src/bidsschematools/utils.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""Utility functions for the bids-specification schema."""

import logging
import os

from . import data

Expand Down Expand Up @@ -29,7 +30,15 @@ def get_logger(name=None):
logging.Logger
logger object.
"""
return logging.getLogger("bidsschematools" + (".%s" % name if name else ""))
logger = logging.getLogger("bidsschematools" + (".%s" % name if name else ""))
# 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"
for lh in logger.handlers:
lh.setFormatter(logging.Formatter(format))

return logger



def set_logger_level(lgr, level):
Expand Down

0 comments on commit e6a8a40

Please sign in to comment.