fix: improve config loading with default values and enhance logging setup

This commit is contained in:
sh4un
2026-01-28 15:35:42 -05:00
parent 56623f9804
commit d45d230ebd
2 changed files with 7 additions and 4 deletions

View File

@@ -113,7 +113,7 @@ def load_config(config_path: str = CONFIG_FILE) -> Optional[BridgeConfig]:
config_path,
)
logger.warning("Using only defaults.")
cfg_section = config["DEFAULT"]
cfg_section = config["DEFAULT"] if "DEFAULT" in config else DEFAULT_CONFIG
meshtastic_port = cfg_section.get(
"MESHTASTIC_SERIAL_PORT",
@@ -126,9 +126,10 @@ def load_config(config_path: str = CONFIG_FILE) -> Optional[BridgeConfig]:
bridge_node_id = cfg_section.get(
"BRIDGE_NODE_ID", fallback=DEFAULT_CONFIG["BRIDGE_NODE_ID"]
)
log_level = cfg_section.get(
"LOG_LEVEL", fallback=DEFAULT_CONFIG["LOG_LEVEL"]
).upper()
log_level_raw = cfg_section.get(
"LOG_LEVEL", DEFAULT_CONFIG["LOG_LEVEL"]
)
log_level = log_level_raw.upper() if isinstance(log_level_raw, str) else DEFAULT_CONFIG["LOG_LEVEL"].upper()
if log_level not in VALID_LOG_LEVELS:
logger.error(

View File

@@ -15,6 +15,8 @@ def setup_logging(log_level_str: str):
"""
Configures application-wide logging.
"""
if not isinstance(log_level_str, str):
log_level_str = "INFO"
numeric_level = getattr(logging, log_level_str.upper(), None)
if not isinstance(numeric_level, int):
logging.warning(