Skip to content

Commit

Permalink
Merge pull request #275 from eliashaeussler/fix/log-uri-object
Browse files Browse the repository at this point in the history
  • Loading branch information
eliashaeussler authored Aug 11, 2023
2 parents 14be3ac + 022dcfb commit 37cd59a
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions src/Http/Message/Handler/LogHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public function onSuccess(Message\ResponseInterface $response, Message\UriInterf
$this->logger->info(
'URL {url} was successfully crawled (status code: {status_code}).',
[
'url' => (string) $uri,
'url' => $uri,
'status_code' => $response->getStatusCode(),
],
);
Expand All @@ -65,7 +65,7 @@ public function onFailure(Throwable $exception, Message\UriInterface $uri): void
$this->logger->error(
'Error while crawling URL {url} (exception: {exception}).',
[
'url' => (string) $uri,
'url' => $uri,
'exception' => $exception->getMessage(),
],
);
Expand Down
8 changes: 4 additions & 4 deletions tests/src/Http/Message/Handler/LogHandlerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ public function onSuccessLogsSuccessfulCrawl(): void
[
'message' => 'URL {url} was successfully crawled (status code: {status_code}).',
'context' => [
'url' => 'https://www.example.com',
'url' => new Psr7\Uri('https://www.example.com'),
'status_code' => 200,
],
],
Expand All @@ -79,7 +79,7 @@ public function onSuccessLogsSuccessfulCrawl(): void
new Psr7\Uri('https://www.example.com'),
);

self::assertSame($expected, $this->logger->log[Log\LogLevel::INFO]);
self::assertEquals($expected, $this->logger->log[Log\LogLevel::INFO]);
}

#[Framework\Attributes\Test]
Expand All @@ -102,7 +102,7 @@ public function onFailureLogsFailedCrawl(): void
[
'message' => 'Error while crawling URL {url} (exception: {exception}).',
'context' => [
'url' => 'https://www.example.com',
'url' => new Psr7\Uri('https://www.example.com'),
'exception' => 'oops, something went wrong.',
],
],
Expand All @@ -113,6 +113,6 @@ public function onFailureLogsFailedCrawl(): void
new Psr7\Uri('https://www.example.com'),
);

self::assertSame($expected, $this->logger->log[Log\LogLevel::ERROR]);
self::assertEquals($expected, $this->logger->log[Log\LogLevel::ERROR]);
}
}

0 comments on commit 37cd59a

Please sign in to comment.