Spaces:
Sleeping
Sleeping
# logger.py | |
import logging | |
from rich.logging import RichHandler | |
from typing import Optional | |
def get_console_logger(name: Optional[str] = "default") -> logging.Logger: | |
logger = logging.getLogger(name) | |
if not logger.handlers: | |
logger.setLevel(logging.DEBUG) | |
console_handler = RichHandler() | |
console_handler.setLevel(logging.DEBUG) | |
formatter = logging.Formatter( | |
"%(asctime)s - %(name)s - %(levelname)s - %(message)s" | |
) | |
console_handler.setFormatter(formatter) | |
logger.addHandler(console_handler) | |
return logger |