Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 12 additions & 23 deletions spec/LoggerPluginSpec.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,20 +45,16 @@ function it_logs_request_and_response(
$logger->info(
"Sending request:\nGET / 1.1",
Argument::that(
function(array $context) use ($request) {
return $context['request'] === $request->getWrappedObject()
&& is_string($context['uid'])
;
function(array $context) {
return is_string($context['uid']);
}
)
)->shouldBeCalled();
$logger->info(
"Received response:\n200 OK 1.1",
Argument::that(
function(array $context) use ($request, $response) {
return $context['request'] === $request->getWrappedObject()
&& $context['response'] === $response->getWrappedObject()
&& is_int($context['milliseconds'])
function(array $context) {
return is_int($context['milliseconds'])
&& is_string($context['uid'])
;
}
Expand All @@ -81,19 +77,16 @@ function it_logs_exception(LoggerInterface $logger, Formatter $formatter, Reques
$logger->info(
"Sending request:\nGET / 1.1",
Argument::that(
function(array $context) use ($request) {
return $context['request'] === $request->getWrappedObject()
&& is_string($context['uid'])
;
function(array $context) {
return is_string($context['uid']);
}
)
)->shouldBeCalled();
$logger->error(
"Error:\nCannot connect\nwhen sending request:\nGET / 1.1",
Argument::that(
function(array $context) use ($request, $exception) {
return $context['request'] === $request->getWrappedObject()
&& $context['exception'] === $exception
function(array $context) use ($exception) {
return $context['exception'] === $exception
&& is_int($context['milliseconds'])
&& is_string($context['uid'])
;
Expand Down Expand Up @@ -122,20 +115,16 @@ function it_logs_response_within_exception(
$logger->info(
"Sending request:\nGET / 1.1",
Argument::that(
function(array $context) use ($request) {
return $context['request'] === $request->getWrappedObject()
&& is_string($context['uid'])
;
function(array $context) {
return is_string($context['uid']);
}
)
)->shouldBeCalled();
$logger->error(
"Error:\nForbidden\nwith response:\n403 Forbidden 1.1",
Argument::that(
function(array $context) use ($request, $response, $exception) {
return $context['request'] === $request->getWrappedObject()
&& $context['response'] === $response->getWrappedObject()
&& $context['exception'] === $exception
function(array $context) use ($exception) {
return $context['exception'] === $exception
&& is_int($context['milliseconds'])
&& is_string($context['uid'])
;
Expand Down
5 changes: 0 additions & 5 deletions src/LoggerPlugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,6 @@ protected function doHandleRequest(RequestInterface $request, callable $next, ca
$this->logger->info(
sprintf("Received response:\n%s", $this->formatter->formatResponse($response)),
[
'request' => $request,
'response' => $response,
'milliseconds' => $milliseconds,
'uid' => $uid,
]
Expand All @@ -54,8 +52,6 @@ protected function doHandleRequest(RequestInterface $request, callable $next, ca
$this->logger->error(
sprintf("Error:\n%s\nwith response:\n%s", $exception->getMessage(), $this->formatter->formatResponse($exception->getResponse())),
[
'request' => $request,
'response' => $exception->getResponse(),
'exception' => $exception,
'milliseconds' => $milliseconds,
'uid' => $uid,
Expand All @@ -65,7 +61,6 @@ protected function doHandleRequest(RequestInterface $request, callable $next, ca
$this->logger->error(
sprintf("Error:\n%s\nwhen sending request:\n%s", $exception->getMessage(), $this->formatter->formatRequest($request)),
[
'request' => $request,
'exception' => $exception,
'milliseconds' => $milliseconds,
'uid' => $uid,
Expand Down