Skip to content

Commit 11eaabc

Browse files
author
Vincent Chalnot
committed
Logging API calls request and response in debug in case of exception
1 parent eb59f02 commit 11eaabc

1 file changed

Lines changed: 14 additions & 1 deletion

File tree

Client/ApiClient.php

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,13 +126,26 @@ protected function getRequest(ApiRequestInterface $apiRequest): Request
126126
protected function getResponseData(
127127
Request $request
128128
): ?string {
129+
$this->logger->debug(
130+
"API Request:{$request->getMethod()} {$request->getUri()}",
131+
[
132+
'body' => $request->getBody(),
133+
]
134+
);
129135
try {
130136
$response = $this->client->sendRequest($request);
131137
} catch (HttpException $e) {
132138
throw ApiRequestException::create($request->getUri(), $e);
133139
}
140+
$body = (string) $response->getBody();
141+
$this->logger->debug(
142+
"API Response:{$request->getMethod()} {$request->getUri()}",
143+
[
144+
'body' => $body,
145+
]
146+
);
134147

135-
return (string) $response->getBody();
148+
return $body;
136149
}
137150

138151
/**

0 commit comments

Comments
 (0)