Skip to content

Commit

Permalink
add service name to log
Browse files Browse the repository at this point in the history
  • Loading branch information
Mohamadhasan Taghadosi committed Aug 9, 2023
1 parent 1e391da commit 03eaa20
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/GuzzleLogger/GuzzleLogger.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ public function __construct($logger)
$this->logger = $logger;
}

public function handleRequestStats($serviceName, $stats) {
public function handleRequestStats($serviceName, $stats)
{
$url = $stats->getHandlerStats()["url"];
$requestDuration = $stats->getTransferTime() * 1000; //ms
$statusCode = 408;
Expand All @@ -27,12 +28,13 @@ public function handleRequestStats($serviceName, $stats) {
public function logRecord(string $serviceName, $statusCode, $response, $requestDuration, $url): void
{
$this->logger->info(
'Third party logger log for: ' . $serviceName . ' service',
'Guzzle logger log for: ' . $serviceName . ' service',
[
"response_status_code" => $statusCode,
"request_duration" => $requestDuration, //ms
"response_body" => $response,
"url" => $url,
"service_name" => $serviceName,
]
);
}
Expand Down

0 comments on commit 03eaa20

Please sign in to comment.