8000 minor #58555 [HttpClient] Add `total_time` to the response log (jwage) · symfony/symfony@b916ed9 · GitHub
[go: up one dir, main page]

Skip to content

Commit b916ed9

Browse files
minor #58555 [HttpClient] Add total_time to the response log (jwage)
This PR was squashed before being merged into the 7.2 branch. Discussion ---------- [HttpClient] Add `total_time` to the response log | Q | A | ------------- | --- | Branch? | 7.2 | Bug fix? | no | New feature? | yes | Deprecations? | no | Issues | | License | MIT This pull request adds the response `total_time` to the info log. - [x] Thoughts on the formatting? Usually in my app code I pass variables to the 2nd argument of `info()` to pass context instead of using sprintf, that way I can parse out variables the logs more easily. Commits ------- c8bfb79 [HttpClient] Add `total_time` to the response log
2 parents f75d358 + c8bfb79 commit b916ed9

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/Symfony/Component/HttpClient/Response/TransportResponseTrait.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,11 @@ public static function stream(iterable $responses, ?float $timeout = null): \Gen
231231
} elseif ($chunk instanceof FirstChunk) {
232232
if ($response->logger) {
233233
$info = $response->getInfo();
234-
$response->logger->info(\sprintf('Response: "%s %s"', $info['http_code'], $info['url']));
234+
$response->logger->info('Response: "{http_code} {url}" {total_time} seconds', [
235+
'http_code' => $info['http_code'],
236+
'url' => $info['url'],
237+
'total_time' => $info['total_time'],
238+
]);
235239
}
236240

237241
$response->inflate = \extension_loaded('zlib') && $response->inflate && 'gzip' === ($response->headers['content-encoding'][0] ?? null) ? inflate_init(\ZLIB_ENCODING_GZIP) : null;

0 commit comments

Comments
 (0)
0