from __future__ import annotations

import logging
import os


_LOG_FORMAT = "%(asctime)s %(levelname)s %(name)s - %(message)s"


def setup_logging() -> None:
    level_name = os.environ.get("AGENT_LOG_LEVEL", "INFO").upper()
    level = getattr(logging, level_name, logging.INFO)
    logging.basicConfig(level=level, format=_LOG_FORMAT)


def get_logger(name: str) -> logging.Logger:
    setup_logging()
    return logging.getLogger(name)
