def get_logs_interactive_handlers()

in wadebug/cli.py [0:0]


def get_logs_interactive_handlers(send, opt_out, logs_folder):
    def prepare_logs():
        if send and opt_out:
            click.secho(
                "Passing --send flag requires to send data to Facebook.\n"
                "It's incompatible with --do-not-send-usage. "
                "Please use only one of those flags.",
                fg="red",
            )
            sys.exit(-1)
        click.echo("Collecting logs on {}\nPlease wait...".format(logs_folder))

    def handle_outputs(log_files, _output, zipped_logs_file_name):
        click.secho("Zipped logs at: {}".format(zipped_logs_file_name), bold=True)
        click.secho("Log files retrieved:\n\t", nl=False, bold=True)
        click.echo("\n\t".join(log_files))

        support_info_file_path = os.path.join(
            log_utils.OUTPUT_FOLDER, log_utils.SUPPORT_INFO_LOG_FILE
        )
        if support_info_file_path not in log_files:
            click.secho(
                "Support Info is an important piece of info that helps us understand "
                "the state of your WhatsApp Business API client. We were not able to "
                "retrieve it because the config file has wrong or missing values.  "
                "Please check and run the logs command again to capture this.",
                fg="yellow",
            )
        # returning _output to keep it consistent with other handle_outputs
        # functions
        _output["success"] = True

        return _output

    def handle_exceptions(exp, _output):
        click.echo("wadebug could not retrieve logs:\n{}\n".format(exp))
        sys.exit(-1)

    def handle_upload_results(output, zipped_logs_file_handle):
        if Config().disable_send_data:
            return

        if send:
            click.echo("Sending logs to Facebook\nPlease wait...")
            cli_utils.send_logs_to_fb(
                zipped_logs_file_handle,
                success_callback=send_logs_result_interactive_success,
                failure_callback=send_result_interactive_failure,
            )
        elif not opt_out:
            click.echo("Sending report to Facebook\nPlease wait...")
            cli_utils.send_results_to_fb(
                output,
                success_callback=send_usage_result_interactive_success,
                failure_callback=send_result_interactive_failure,
            )

    return prepare_logs, handle_outputs, handle_exceptions, handle_upload_results