def METHOD_NAME(level, format_str=None):
    """
    inputs:
        level: one of 'DEBUG', 'INFO', 'WARNING', 'ERROR', 'CRITICAL'
        format_str: input to logging.setFormatter
    Returns a logging.StreamHandler object
    """
    if format_str is None:
        format_str = "{asctime} {color}{levelname:8}{reset} {message}"
    console_formatter = ColoredFormatter(
        format_str,
        style="{",
        datefmt="%Y-%m-%d %H:%M:%S",
        colors={
            "DEBUG": Fore.CYAN,
            "INFO": Fore.GREEN,
            "WARNING": Fore.YELLOW,
            "ERROR": Fore.RED,
            "CRITICAL": Fore.WHITE + Back.RED,
        },
    )
    console_handler = logging.StreamHandler(sys.stdout)
    console_handler.setFormatter(console_formatter)
    console_handler.setLevel(levels[level])
    return console_handler