示例#1
0
def main(
    ctx: click.Context,
    config_path: T.Optional[T.Text],
    host: T.Text,
    port: int,
    log_level: T.Text,
    syslog: bool,
    log_file: T.Optional[T.Text],
    graphiql: bool,
):
    """Console script for kofi."""
    shell_config = {}  # type: T.Dict[T.Text, T.Any]
    if host:
        shell_config["host"] = host
    if port:
        shell_config["port"] = port
    log_conf = {
        "level": log_level,
        "syslog": syslog,
    }
    if log_file:
        log_conf["log_file"] = log_file
    if log_level or syslog or log_file:
        shell_config["log"] = log_conf
    if graphiql:
        shell_config["graphiql"] = True
    config = read_config(config_path)
    def_config = merge_configs(config, shell_config)

    if log_level and log_level.upper() == "DEBUG":
        click.echo("Resulting conf:\n{}".format(pformat(def_config)))

    run_from_shell(def_config)
示例#2
0
def cli(log_level: t.Text):
    if log_level:
        log_level = log_level.upper()
        logging.basicConfig(level=log_level)
        coloredlogs.install(level=log_level)
        logging.info("Setting Log Level from CLI argument to '%s'.", log_level)
    _ = SystemSettings().update_installed_runners()