コード例 #1
0
 /**
  * @param \Magento\Framework\HTTP\Adapter\Curl $subject
  * @param $result
  * @return mixed
  */
 public function afterRead(\Magento\Framework\HTTP\Adapter\Curl $subject, $result)
 {
     try {
         /* @var $curlLog \Foggyline\Sentinel\Model\CurlLog */
         $curlLog = $this->curlLog->create();
         $curlLog->setRequestId($this->helper->getHttpRequestUniqueId());
         $curlLog->setResult($result);
         $curlLog->setMethod($this->cUrlMethod);
         $curlLog->setUrl($this->cUrlUrl);
         $curlLog->setHttpVer($this->cUrlHttpVer);
         $curlLog->setHeaders(serialize($this->cUrlHeaders));
         $curlLog->setBody($this->cUrlBody);
         $curlLog->setHttpCode($subject->getInfo(CURLINFO_HTTP_CODE));
         $curlLog->setTotalTime($subject->getInfo(CURLINFO_TOTAL_TIME));
         $curlLog->setNameLookupTime($subject->getInfo(CURLINFO_NAMELOOKUP_TIME));
         $curlLog->setPrimaryIp($subject->getInfo(CURLINFO_PRIMARY_IP));
         $curlLog->setPrimaryPort($subject->getInfo(CURLINFO_PRIMARY_PORT));
         $curlLog->setLocalIp($subject->getInfo(CURLINFO_LOCAL_IP));
         $curlLog->setLocalPort($subject->getInfo(CURLINFO_LOCAL_PORT));
         $curlLog->setSizeUpload($subject->getInfo(CURLINFO_SIZE_UPLOAD));
         $curlLog->setSizeDownload($subject->getInfo(CURLINFO_SIZE_DOWNLOAD));
         $curlLog->setSpeedUpload($subject->getInfo(CURLINFO_SPEED_UPLOAD));
         $curlLog->setSpeedDownload($subject->getInfo(CURLINFO_SPEED_DOWNLOAD));
         $curlLog->setContentType($subject->getInfo(CURLINFO_CONTENT_TYPE));
         $curlLog->save();
     } catch (\Exception $e) {
         $this->logger->critical($e);
     }
     return $result;
 }
コード例 #2
0
 /**
  * @param int $logId
  * @return mixed
  * @throws \Magento\Framework\Exception\NoSuchEntityException
  */
 public function getById($logId)
 {
     $log = $this->logFactory->create();
     $this->resource->load($log, $logId);
     if (!$log->getId()) {
         throw new \Magento\Framework\Exception\NoSuchEntityException(__('CurlLog with id "%1" does not exist.', $logId));
     }
     return $log;
 }