arina-hf-spaces-api / app /core /logging_setup.py
adsurkasur's picture
clone from arina-hf-spaces
68964c2
raw
history blame contribute delete
723 Bytes
import logging
import logging.config
import yaml
from pathlib import Path
logger = logging.getLogger("arina_hf")
def setup_logging():
config_path = Path("configs/log_config.yaml")
if config_path.exists():
with config_path.open("r") as f:
config = yaml.safe_load(f)
log_file_path = Path(config['handlers']['file']['filename'])
log_file_path.parent.mkdir(parents=True, exist_ok=True)
logging.config.dictConfig(config)
logger.info("✅ Logging configured from YAML.")
else:
logging.basicConfig(level=logging.INFO, format="%(asctime)s - %(levelname)s - %(message)s")
logger.warning("⚠️ log_config.yaml not found. Using basicConfig instead.")