def _pprint_response()

in src/mapillary/models/client.py [0:0]


    def _pprint_response(res):
        """
        Format::

            HTTP/version status_code status_text
            Header_key: Header_value
            Body

        :param res: Response object returned from the API request

        Reference::

            1. 'https://github.com/michaeldbianchi/Python-API-Client-Boilerplate/blob/fd1c82be9e98e'
                '24730c4631ffc30068272386669/exampleClient.py#L230'
        """

        http_v0, http_v1 = list(str(res.raw.version))
        http_v = f"HTTP/{http_v0}.{http_v1}"
        status_code = res.status_code
        status_text = res.reason
        headers = "\n".join(f"{k}: {v}" for k, v in res.headers.items())
        body = res.text or ""

        # Convert timedelta to milliseconds
        elapsed = floor(res.elapsed.total_seconds() * 1000)

        logger.info(f"Response {status_code} {status_text} received in {elapsed}ms")

        logger.debug(
            "{}\n{} {} {}\n{}\n\n{}".format(
                "-----------RESPONSE-----------",
                http_v,
                status_code,
                status_text,
                headers,
                body,
            )
        )