def configure_logger(level: int | str = logging.INFO) -> None:
    """Configure console logging with consistent formatting.

    This function sets up console logging with a standardized format and rich
    tracebacks. It configures both the root logger and PyTorch Lightning logger
    to use the same formatting.

    Args:
        level (int | str): Logging level to use. Can be either a string name like
            ``"INFO"`` or an integer constant like ``logging.INFO``. Defaults to
            ``logging.INFO``.

    Example:
        >>> from anomalib.loggers import configure_logger
        >>> configure_logger(level="DEBUG")  # doctest: +SKIP
        >>> logger = logging.getLogger("my_logger")
        >>> logger.info("Test message")  # doctest: +SKIP
        2024-01-01 12:00:00 - my_logger - INFO - Test message
    """
    if isinstance(level, str):
        level = logging.getLevelName(level)

    format_string = "%(asctime)s - %(name)s - %(levelname)s - %(message)s"
    logging.basicConfig(format=format_string, level=level)
    logging.getLogger().addHandler(RichHandler(rich_tracebacks=True))

    # Set Pytorch Lightning logs to have a the consistent formatting with anomalib.
    for handler in logging.getLogger("lightning.pytorch").handlers:
        handler.setFormatter(logging.Formatter(format_string))
        handler.setLevel(level)
    logging.getLogger("lightning.pytorch").addHandler(RichHandler(rich_tracebacks=True))
Configure console logging with consistent formatting.

    This function sets up console logging with a standardized format and rich
    tracebacks. It configures both the root logger and PyTorch Lightning logger
    to use the same formatting.

    Args:
        level (int | str): Logging level to use. Can be either a string name like
            ``"INFO"`` or an integer constant like ``logging.INFO``. Defaults to
            ``logging.INFO``.

    Example:
        >>> from anomalib.loggers import configure_logger
        >>> configure_logger(level="DEBUG")  # doctest: +SKIP
        >>> logger = logging.getLogger("my_logger")
        >>> logger.info("Test message")  # doctest: +SKIP
        2024-01-01 12:00:00 - my_logger - INFO - Test message
    
src/anomalib/loggers/__init__.py