Skip to content

Commit

Permalink
Fix handler enable checking
Browse files Browse the repository at this point in the history
This ensures the backwards compatibility is still carried forward of
enabling misconfigured handlers.
  • Loading branch information
jinnatar committed Feb 7, 2023
1 parent 0d133b8 commit d12b99a
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/chia_log/log_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

# lib
from confuse import ConfigView
from confuse.exceptions import ConfigTypeError

# project
from src.chia_log.handlers import LogHandlerInterface
Expand All @@ -21,8 +22,8 @@ def _check_handler_enabled(config: dict, handler_name: str) -> bool:
"""Fallback to True for backwards compatability"""
try:
return config["handlers"][handler_name]["enable"].get(bool)
except KeyError as key:
logging.error(f"Invalid config.yaml. Missing key: {key}")
except ConfigTypeError as e:
logging.error(f"Invalid config.yaml, enabling handler anyway: {e}")
return True


Expand Down

0 comments on commit d12b99a

Please sign in to comment.