private function _handleTransportException(Exception $e, ehough_shortstop_api_HttpRequest $request, ehough_chaingang_api_Context $context, $isDebugEnabled, ehough_epilog_psr_LoggerInterface $logger) { $this->_tearDown($request, true); /** * Fire an error event. */ $transportFailureEvent = new ehough_tickertape_GenericEvent($this, array('request' => $request, 'response' => $context->containsKey('response') ? $context->get('response') : null, 'exception' => $e, 'rethrow' => false, 'tryOtherTransports' => true)); $this->_eventDispatcher->dispatch(ehough_shortstop_api_Events::TRANSPORT_FAILURE, $transportFailureEvent); if ($transportFailureEvent->getArgument('rethrow')) { if ($isDebugEnabled) { $logger->error(sprintf('Caught exception when handling %s (%s). Will re-throw.', $request, $e->getMessage())); } throw new ehough_shortstop_api_exception_RuntimeException($e->getMessage()); } if ($transportFailureEvent->getArgument('tryOtherTransports')) { if ($isDebugEnabled) { $logger->debug('Transport failed, but trying the next...'); } return false; } if ($isDebugEnabled) { $logger->debug('Transport failed, and not trying any others...'); } return true; }
private function _logSuccess(ehough_epilog_psr_LoggerInterface $logger, $before, $after) { $ratio = 100; if ($before != 0) { $ratio = number_format($after / $before * 100, 2); } $logger->debug(sprintf('Successfully decoded entity. Result is %s' . '%% of the original size (%s / %s).', $ratio, $after, $before)); }