Skip to content

Commit

Permalink
Read logging.yml automatically
Browse files Browse the repository at this point in the history
Signed-off-by: Nok <nok.lam.chan@quantumblack.com>
  • Loading branch information
noklam committed Feb 27, 2024
1 parent 7a0d7d0 commit be3d28d
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions kedro/framework/project/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -217,9 +217,14 @@ class _ProjectLogging(UserDict):
def __init__(self) -> None:
"""Initialise project logging. The path to logging configuration is given in
environment variable KEDRO_LOGGING_CONFIG (defaults to default_logging.yml)."""
path = os.environ.get(
"KEDRO_LOGGING_CONFIG", Path(__file__).parent / "default_logging.yml"
)
user_logging_path = os.environ.get("KEDRO_LOGGING_CONFIG")
if not user_logging_path and Path("conf/logging.yml").exists():
user_logging_path = Path("conf/logging.yml")

default_logging_path = Path(__file__).parent / "default_logging.yml"
path = user_logging_path if user_logging_path else default_logging_path
print(f"DEBUG: {path=}")

logging_config = Path(path).read_text(encoding="utf-8")
self.configure(yaml.safe_load(logging_config))

Expand Down

0 comments on commit be3d28d

Please sign in to comment.