Пример #1
0
 function it_can_serialize(ApiCallInterface $apiCall, DateTime $requestDateTime)
 {
     $duration = 1.23;
     $request = '<request />';
     $response = '<response />';
     $dateTimeFormatted = '1970-01-01T00:00:01+00:00';
     $identity = 'my id';
     $method = 'My::method()';
     $endpoint = 'https://my.endpoint';
     $reference = 'my ref';
     $apiCall->getDuration()->willReturn($duration);
     $apiCall->getRequest()->willReturn($request);
     $apiCall->getResponse()->willReturn($response);
     $requestDateTime->format('c')->willReturn($dateTimeFormatted);
     $apiCall->getRequestDateTime()->willReturn($requestDateTime);
     $apiCall->getId()->willReturn($identity);
     $apiCall->getMethod()->willReturn($method);
     $apiCall->getEndpoint()->willReturn($endpoint);
     $apiCall->getReference()->willReturn($reference);
     $data = json_encode(array('duration' => $duration, 'request' => $request, 'response' => $response));
     $expectedString = sprintf('[%s] (%s) %s (%s) | %s - %s%s', $dateTimeFormatted, $identity, $method, $endpoint, $reference, $data, "\n");
     $this->__invoke($apiCall)->shouldReturn($expectedString);
 }
Пример #2
0
 /**
  * {@inheritdoc}
  */
 public function __invoke(ApiCallInterface $apiCall)
 {
     $data = json_encode(array('duration' => $apiCall->getDuration(), 'request' => $apiCall->getRequest(), 'response' => $apiCall->getResponse()));
     return sprintf('[%s] (%s) %s (%s) | %s - %s%s', $apiCall->getRequestDateTime()->format('c'), $apiCall->getId(), $apiCall->getMethod(), $apiCall->getEndpoint(), $apiCall->getReference(), $data, $this->eol);
 }
Пример #3
0
 /**
  * @param Exception $exception
  * @param ApiCallInterface $apiCall
  * @return void
  */
 protected function logHandlerException(Exception $exception, ApiCallInterface $apiCall)
 {
     if ($this->psrLogger === null) {
         return;
     }
     $this->psrLogger->warning($exception->getMessage(), array('exception' => $exception, 'endpoint' => $apiCall->getEndpoint(), 'method' => $apiCall->getMethod(), 'reference' => $apiCall->getReference(), 'request' => $apiCall->getRequest(), 'response' => $apiCall->getResponse()));
 }