src/Google/AdsApi/Common/GuzzleLogMessageFormatter.php
public function formatDetailed(
        RequestInterface $request,
        ResponseInterface &$response = null,
        Exception &$error = null
    ) {
        $needRewind = $this->shouldLogResponsePayload
            && !is_null($response) && !is_null($response->getBody());
        // Create a new response with its body as a rewindable caching stream.
        // This is needed when we want to both log the response body
        // and use it in other cases, e.g. creating an exception with this
        // response body, reading the content of the downloaded report.
        if ($needRewind && !$response->getBody()->isSeekable()) {
            $response =
                $response->withBody(new CachingStream($response->getBody()));

            if (!is_null($error)) {
                // Creates a new RequestException with the response whose stream
                // can be rewound.
                $error = RequestException::create(
                    $request,
                    $response,
                    $error
                );
            }
        }

        $detailedLog =
            $this->scrubAndFormatDetailedMessage($request, $response, $error);

        // Rewind the response stream so it can be used again, e.g. reading
        // the content of the downloaded report.
        if ($needRewind) {
            \GuzzleHttp\Psr7\rewind_body($response);
        }

        return $detailedLog;
    }
public function formatDetailed(
        RequestInterface $request,
        ResponseInterface &$response = null,
        Exception &$error = null
    ) {
        $needRewind = $this->shouldLogResponsePayload
            && !is_null($response) && !is_null($response->getBody());
        // Create a new response with its body as a rewindable caching stream.
        // This is needed when we want to both log the response body
        // and use it in other cases, e.g. creating an exception with this
        // response body, reading the content of the downloaded report.
        if ($needRewind && !$response->getBody()->isSeekable()) {
            $response =
                $response->withBody(new CachingStream($response->getBody()));

            if (!is_null($error)) {
                // Creates a new RequestException with the response whose stream
                // can be rewound.
                $error = RequestException::create(
                    $request,
                    $response,
                    $error
                );
            }
        }

        $detailedLog =
            $this->scrubAndFormatDetailedMessage($request, $response, $error);

        // Rewind the response stream so it can be used again, e.g. reading
        // the content of the downloaded report.
        if ($needRewind) {
            \GuzzleHttp\Psr7\rewind_body($response);
        }

        return $detailedLog;
    }
public function formatDetailed ( RequestInterface $ request , ResponseInterface & $ response = null , Exception & $ error = null ) { $ needRewind = $ this -> shouldLogResponsePayload && ! is_null ( $ response ) && ! is_null ( $ response -> getBody ( ) ) ; // Create a new response with its body as a rewindable caching stream. // This is needed when we want to both log the response body // and use it in other cases, e.g. creating an exception with this // response body, reading the content of the downloaded report. if ( $ needRewind && ! $ response -> getBody ( ) -> isSeekable ( ) ) { $ response = $ response -> withBody ( new CachingStream ( $ response -> getBody ( ) ) ) ; if ( ! is_null ( $ error ) ) { // Creates a new RequestException with the response whose stream // can be rewound. $ error = RequestException :: create ( $ request , $ response , $ error ) ; } } $ detailedLog = $ this -> scrubAndFormatDetailedMessage ( $ request , $ response , $ error ) ; // Rewind the response stream so it can be used again, e.g. reading // the content of the downloaded report. if ( $ needRewind ) { \ GuzzleHttp \ Psr7 \ rewind_body ( $ response ) ; } return $ detailedLog ; }
Formats a detailed message based on the specified HTTP request and
response, and errors, if present. This function also replaces the
original response with a new one with a seekable stream, if the original
one contains forward-only stream.

@param RequestInterface $request the HTTP request
@param ResponseInterface|null &$response the HTTP response containing the
body to be formatted. This original response with forward-only body
stream will be replaced with a new response with a seekable stream
@param Exception|null &$error the HTTP error whose body would be modified
to use a seekable stream
@return string the formatted detailed log message
Formats a detailed message based on the specified HTTP request and response and errors if present . This function also replaces the original response with a new one with a seekable stream if the original one contains forward - only stream .