import logging, coloredlogs

def logsetup(filename, format, loglevel):
    logging.basicConfig(filename=filename, level=loglevel)
    root = logging.getLogger()

    sh = logging.StreamHandler()
    sh.setLevel(loglevel)

    formatter = coloredlogs.ColoredFormatter(fmt=format, field_styles={
        "hostname": {"color": "blue"},
        "programname": {"color": "cyan"},
        "name": {"color": "red"},
        "levelname": {"color": "magenta"},
        "asctime": {"color": "cyan"}
    })

    sh.setFormatter(formatter)
    root.addHandler(sh)

    return logging.getLogger("kickbot")
