def init_log(log_level=WARNING, log_path=True, log_truncate=False,
             log_size=10000000, log_numbackups=1, log_color=True):
    formatter = Formatter(
        "%(asctime)s %(levelname)s %(name)s %(filename)s:%(funcName)s():L%(lineno)d %(message)s"
    )

    # We'll always use a stream handler
    stream_handler = StreamHandler(sys.stdout)
    if log_color:
        color_formatter = ColorFormatter(
            '$RESET$COLOR%(asctime)s $BOLD$COLOR%(name)s %(filename)s:%(funcName)s():L%(lineno)d $RESET %(message)s'
        )
        stream_handler.setFormatter(color_formatter)
    else:
        stream_handler.setFormatter(formatter)
    logger.addHandler(stream_handler)

    # If we have a log path, we'll also setup a log file
    if log_path:
        if not isinstance(log_path, str):
            data_directory = os.path.expandvars('$XDG_DATA_HOME')
            if data_directory == '$XDG_DATA_HOME':
                # if variable wasn't set
                data_directory = os.path.expanduser("~/.local/share")
            data_directory = os.path.join(data_directory, 'qtile')
            if not os.path.exists(data_directory):
                os.makedirs(data_directory)
            log_path = os.path.join(data_directory, '%s.log')
        try:
            log_path %= 'qtile'
        except __HOLE__:  # Happens if log_path doesn't contain formatters.
            pass
        log_path = os.path.expanduser(log_path)
        if log_truncate:
            with open(log_path, "w"):
                pass
        file_handler = RotatingFileHandler(
            log_path,
            maxBytes=log_size,
            backupCount=log_numbackups
        )

        file_handler.setFormatter(formatter)
        logger.addHandler(file_handler)

    logger.setLevel(log_level)
    # Capture everything from the warnings module.
    captureWarnings(True)
    warnings.simplefilter("always")
    logger.warning('Starting logging for Qtile')
    return logger
dataset/ETHPy150Open qtile/qtile/libqtile/log_utils.py/init_log