import sys

from loguru import logger

_VERBOSE_FORMAT = (
    "<green>{time:HH:mm:ss}</green> | "
    "<level>{level: <8}</level> | "
    "<cyan>{name}</cyan>:<cyan>{function}</cyan>:<cyan>{line}</cyan> - "
    "<level>{message}</level>"
)
_INFO_FORMAT = "<level>{level: <8}</level> | {message}"


def setup_logging(verbose: bool = False) -> None:
    logger.remove()
    level = "DEBUG" if verbose else "INFO"
    fmt = _VERBOSE_FORMAT if verbose else _INFO_FORMAT
    logger.add(sys.stderr, level=level, format=fmt)
