import logging


def get_formatted_logger(log_level):
    """
    Helper function to create and return a formatted logger
    """

    class CustomLogFormatter(logging.Formatter):
        def __init__(self):
            super().__init__(datefmt="%Y-%m-%d %H:%M:%S")

        def format(self, record):
            if record.levelno == logging.INFO:
                self._style._fmt = "%(msg)s"
            else:
                self._style._fmt = "[%(asctime)s.%(msecs)03d][%(levelname)s] %(msg)s"

            return logging.Formatter.format(self, record)

    # logger = logging.getLogger("logging")
    logger = logging.getLogger(__name__)
    logger.setLevel(log_level)
    console_handler = logging.StreamHandler()
    console_handler.setLevel(log_level)
    console_handler.setFormatter(CustomLogFormatter())
    logger.addHandler(console_handler)

    return logger