import logging
from gumband_python_sdk.config import config


def get_local_logger(name="gumband"):
    logger = logging.getLogger(name)

    if not logger.handlers:
        handler = logging.StreamHandler()
        formatter = logging.Formatter("%(asctime)s - %(name)s - %(levelname)s - %(message)s")
        handler.setFormatter(formatter)
        logger.addHandler(handler)

    logger.setLevel(logging.getLevelNamesMapping()[config["local_log_level"]])
    logger.debug(f"Local log level set to {config['local_log_level']}")
    return logger
