| import logging | |
| from rich.logging import RichHandler | |
| from src.common.config import settings | |
| def configure_logger() -> None: | |
| """ | |
| Configures the root logger with RichHandler and sets the log level based on settings. | |
| """ | |
| if settings.ENVIRONMENT == "local": | |
| logging.basicConfig( | |
| level=settings.LOG_LEVEL, | |
| format="%(message)s", | |
| datefmt="[%X]", | |
| handlers=[ | |
| RichHandler( | |
| rich_tracebacks=True, | |
| tracebacks_show_locals=True, | |
| enable_link_path=False, | |
| ) | |
| ], | |
| ) | |
| else: | |
| logging.basicConfig( | |
| level=settings.LOG_LEVEL, | |
| format="%(asctime)s - %(name)s - %(levelname)s \n%(message)s", | |
| datefmt="[%X]", | |
| ) | |
| def get_logger(name: str) -> logging.Logger: | |
| """ | |
| Returns a logger instance with the given name. | |
| """ | |
| return logging.getLogger(name) | |
| configure_logger() | |