当前位置: 首页>>代码示例>>PHP>>正文


PHP Framework\Logger类代码示例

本文整理汇总了PHP中Magento\Framework\Logger的典型用法代码示例。如果您正苦于以下问题:PHP Logger类的具体用法?PHP Logger怎么用?PHP Logger使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了Logger类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: _getCommand

 /**
  * Get command object
  *
  * @param array $data command params
  * @param \Magento\Framework\Logger $logger
  * @return \Magento\Backend\Model\Menu\Builder\AbstractCommand
  */
 protected function _getCommand($data, $logger)
 {
     $command = $this->_commandFactory->create($data['type'], array('data' => $data));
     if (isset($this->_messagePatterns[$data['type']])) {
         $logger->logDebug(sprintf($this->_messagePatterns[$data['type']], $command->getId()), \Magento\Backend\Model\Menu::LOGGER_KEY);
     }
     return $command;
 }
开发者ID:aiesh,项目名称:magento2,代码行数:15,代码来源:Director.php

示例2: get

 /**
  * Get storage instance
  *
  * @param array $arguments
  * @return \Magento\Store\Model\StoreManagerInterface
  * @throws \InvalidArgumentException
  */
 public function get(array $arguments = array())
 {
     $className = $this->_appState->isInstalled() ? $this->_installedStorageClassName : $this->_defaultStorageClassName;
     if (false == isset($this->_cache[$className])) {
         /** @var $storage \Magento\Store\Model\StoreManagerInterface */
         $storage = $this->_objectManager->create($className, $arguments);
         if (false === $storage instanceof \Magento\Store\Model\StoreManagerInterface) {
             throw new \InvalidArgumentException($className . ' doesn\'t implement \\Magento\\Store\\Model\\StoreManagerInterface');
         }
         $this->_cache[$className] = $storage;
         if ($className === $this->_installedStorageClassName) {
             $this->_reinitStores($storage, $arguments);
             $useSid = $this->_scopeConfig->isSetFlag(\Magento\Framework\Session\SidResolver::XML_PATH_USE_FRONTEND_SID, \Magento\Store\Model\ScopeInterface::SCOPE_STORE, $storage->getStore());
             $this->_sidResolver->setUseSessionInUrl($useSid);
             $this->_eventManager->dispatch('core_app_init_current_store_after');
             $store = $storage->getStore(true);
             $logActive = $this->_scopeConfig->isSetFlag('dev/log/active', \Magento\Store\Model\ScopeInterface::SCOPE_STORE, $store);
             if ($logActive || $this->_appState->getMode() === \Magento\Framework\App\State::MODE_DEVELOPER) {
                 $logFile = $this->_scopeConfig->getValue('dev/log/file', \Magento\Store\Model\ScopeInterface::SCOPE_STORE, $store);
                 $logExceptionFile = $this->_scopeConfig->getValue('dev/log/exception_file', \Magento\Store\Model\ScopeInterface::SCOPE_STORE, $store);
                 $this->_log->unsetLoggers();
                 $this->_log->addStreamLog(\Magento\Framework\Logger::LOGGER_SYSTEM, $logFile, $this->_writerModel);
                 $this->_log->addStreamLog(\Magento\Framework\Logger::LOGGER_EXCEPTION, $logExceptionFile, $this->_writerModel);
             }
         }
     }
     return $this->_cache[$className];
 }
开发者ID:Atlis,项目名称:docker-magento2,代码行数:35,代码来源:StorageFactory.php

示例3: addException

 /**
  * Not Magento exception handling
  *
  * @param \Exception $exception
  * @param string $alternativeText
  * @param string $group
  * @return $this
  */
 public function addException(\Exception $exception, $alternativeText, $group = null)
 {
     $message = sprintf('Exception message: %s%sTrace: %s', $exception->getMessage(), "\n", $exception->getTraceAsString());
     $this->logger->logFile($message, \Zend_Log::DEBUG, Logger::LOGGER_EXCEPTION);
     $this->addMessage($this->messageFactory->create(MessageInterface::TYPE_ERROR, $alternativeText), $group);
     return $this;
 }
开发者ID:,项目名称:,代码行数:15,代码来源:

示例4: build

 /**
  * Build product based on user request
  *
  * @param RequestInterface $request
  * @return \Magento\Catalog\Model\Product
  */
 public function build(RequestInterface $request)
 {
     $productId = (int) $request->getParam('id');
     /** @var $product \Magento\Catalog\Model\Product */
     $product = $this->productFactory->create();
     $product->setStoreId($request->getParam('store', 0));
     $typeId = $request->getParam('type');
     if (!$productId && $typeId) {
         $product->setTypeId($typeId);
     }
     $product->setData('_edit_mode', true);
     if ($productId) {
         try {
             $product->load($productId);
         } catch (\Exception $e) {
             $product->setTypeId(\Magento\Catalog\Model\Product\Type::DEFAULT_TYPE);
             $this->logger->logException($e);
         }
     }
     $setId = (int) $request->getParam('set');
     if ($setId) {
         $product->setAttributeSetId($setId);
     }
     $this->registry->register('product', $product);
     $this->registry->register('current_product', $product);
     $this->wysiwygConfig->setStoreId($request->getParam('store'));
     return $product;
 }
开发者ID:aiesh,项目名称:magento2,代码行数:34,代码来源:Builder.php

示例5: execute

 /**
  * Get associated grouped products grid popup
  *
  * @return void
  */
 public function execute()
 {
     $productId = (int) $this->getRequest()->getParam('id');
     /** @var $product \Magento\Catalog\Model\Product */
     $product = $this->factory->create();
     $product->setStoreId($this->getRequest()->getParam('store', 0));
     $typeId = $this->getRequest()->getParam('type');
     if (!$productId && $typeId) {
         $product->setTypeId($typeId);
     }
     $product->setData('_edit_mode', true);
     if ($productId) {
         try {
             $product->load($productId);
         } catch (\Exception $e) {
             $product->setTypeId(\Magento\Catalog\Model\Product\Type::DEFAULT_TYPE);
             $this->logger->logException($e);
         }
     }
     $setId = (int) $this->getRequest()->getParam('set');
     if ($setId) {
         $product->setAttributeSetId($setId);
     }
     $this->registry->register('current_product', $product);
     $this->_view->loadLayout(false);
     $this->_view->renderLayout();
 }
开发者ID:aiesh,项目名称:magento2,代码行数:32,代码来源:Popup.php

示例6: testIndexActionException

 public function testIndexActionException()
 {
     $this->request->expects($this->once())->method('isPost')->will($this->returnValue(true));
     $exception = new \Exception();
     $this->request->expects($this->once())->method('getPost')->will($this->throwException($exception));
     $this->logger->expects($this->once())->method('logException')->with($this->identicalTo($exception));
     $this->response->expects($this->once())->method('setHttpResponseCode')->with(500);
     $this->model->execute();
 }
开发者ID:,项目名称:,代码行数:9,代码来源:

示例7: invoke

 /**
  * Create order
  *
  * @param \Magento\Sales\Service\V1\Data\Order $orderDataObject
  * @return bool
  * @throws \Exception
  */
 public function invoke(\Magento\Sales\Service\V1\Data\Order $orderDataObject)
 {
     try {
         $order = $this->orderConverter->getModel($orderDataObject);
         return (bool) $order->save();
     } catch (\Exception $e) {
         $this->logger->logException($e);
         throw new \Exception(__('An error has occurred during order creation'));
     }
 }
开发者ID:aiesh,项目名称:magento2,代码行数:17,代码来源:OrderCreate.php

示例8: send

 /**
  * Send email about new order.
  * Process mail exception
  *
  * @param Order $order
  * @return bool
  */
 public function send(Order $order)
 {
     try {
         $this->orderSender->send($order);
     } catch (\Magento\Framework\Mail\Exception $exception) {
         $this->logger->logException($exception);
         $this->messageManager->addWarning(__('You did not email your customer. Please check your email settings.'));
         return false;
     }
     return true;
 }
开发者ID:aiesh,项目名称:magento2,代码行数:18,代码来源:EmailSender.php

示例9: execute

 /**
  * Instantiate IPN model and pass IPN request to it
  *
  * @return void
  */
 public function execute()
 {
     if (!$this->getRequest()->isPost()) {
         return;
     }
     try {
         $data = $this->getRequest()->getPost();
         $this->_ipnFactory->create(array('data' => $data))->processIpnRequest();
     } catch (\Exception $e) {
         $this->_logger->logException($e);
     }
 }
开发者ID:Atlis,项目名称:docker-magento2,代码行数:17,代码来源:Index.php

示例10: beforeDispatch

 /**
  * Clear temporary directories
  *
  * @param \Magento\Install\Controller\Index\Index $subject
  * @param \Magento\Framework\App\RequestInterface $request
  *
  * @return void
  * @SuppressWarnings(PHPMD.UnusedFormalParameter)
  */
 public function beforeDispatch(\Magento\Install\Controller\Index\Index $subject, \Magento\Framework\App\RequestInterface $request)
 {
     if (!$this->appState->isInstalled()) {
         foreach ($this->varDirectory->read() as $dir) {
             if ($this->varDirectory->isDirectory($dir)) {
                 try {
                     $this->varDirectory->delete($dir);
                 } catch (FilesystemException $exception) {
                     $this->logger->log($exception->getMessage());
                 }
             }
         }
     }
 }
开发者ID:aiesh,项目名称:magento2,代码行数:23,代码来源:Dir.php

示例11: log

 /**
  * Perform forced log data to file
  *
  * @param mixed $data
  * @return $this
  */
 public function log($data = null)
 {
     if ($data === null) {
         $data = $this->_data;
     } else {
         if (!is_array($data)) {
             $data = array($data);
         }
     }
     $data = $this->_filterDebugData($data);
     $data['__pid'] = getmypid();
     $this->_logger->logFile($data, \Zend_Log::DEBUG, $this->_logFileName);
     return $this;
 }
开发者ID:,项目名称:,代码行数:20,代码来源:

示例12: _getTZOffsetTransitions

 /**
  * Retrieve transitions for offsets of given timezone
  *
  * @param string $timezone
  * @param mixed $from
  * @param mixed $to
  * @return array
  */
 protected function _getTZOffsetTransitions($timezone, $from = null, $to = null)
 {
     $tzTransitions = array();
     try {
         if (!empty($from)) {
             $from = new \Magento\Framework\Stdlib\DateTime\Date($from, \Magento\Framework\Stdlib\DateTime::DATETIME_INTERNAL_FORMAT);
             $from = $from->getTimestamp();
         }
         $to = new \Magento\Framework\Stdlib\DateTime\Date($to, \Magento\Framework\Stdlib\DateTime::DATETIME_INTERNAL_FORMAT);
         $nextPeriod = $this->_getWriteAdapter()->formatDate($to->toString(\Magento\Framework\Stdlib\DateTime::DATETIME_INTERNAL_FORMAT));
         $to = $to->getTimestamp();
         $dtz = new \DateTimeZone($timezone);
         $transitions = $dtz->getTransitions();
         $dateTimeObject = new \Magento\Framework\Stdlib\DateTime\Date('c');
         for ($i = count($transitions) - 1; $i >= 0; $i--) {
             $tr = $transitions[$i];
             try {
                 $this->timezoneValidator->validate($tr['ts'], $to);
             } catch (\Magento\Framework\Stdlib\DateTime\Timezone\ValidationException $e) {
                 continue;
             }
             $dateTimeObject->set($tr['time']);
             $tr['time'] = $this->_getWriteAdapter()->formatDate($dateTimeObject->toString(\Magento\Framework\Stdlib\DateTime::DATETIME_INTERNAL_FORMAT));
             $tzTransitions[$tr['offset']][] = array('from' => $tr['time'], 'to' => $nextPeriod);
             if (!empty($from) && $tr['ts'] < $from) {
                 break;
             }
             $nextPeriod = $tr['time'];
         }
     } catch (\Exception $e) {
         $this->_logger->logException($e);
     }
     return $tzTransitions;
 }
开发者ID:aiesh,项目名称:magento2,代码行数:42,代码来源:AbstractReport.php

示例13: scheduledBackup

 /**
  * Create Backup
  *
  * @return $this
  */
 public function scheduledBackup()
 {
     if (!$this->_scopeConfig->isSetFlag(self::XML_PATH_BACKUP_ENABLED, ScopeInterface::SCOPE_STORE)) {
         return $this;
     }
     if ($this->_scopeConfig->isSetFlag(self::XML_PATH_BACKUP_MAINTENANCE_MODE, ScopeInterface::SCOPE_STORE)) {
         $this->maintenanceMode->set(true);
     }
     $type = $this->_scopeConfig->getValue(self::XML_PATH_BACKUP_TYPE, ScopeInterface::SCOPE_STORE);
     $this->_errors = array();
     try {
         $backupManager = $this->_backupFactory->create($type)->setBackupExtension($this->_backupData->getExtensionByType($type))->setTime(time())->setBackupsDir($this->_backupData->getBackupsDir());
         $this->_coreRegistry->register('backup_manager', $backupManager);
         if ($type != \Magento\Framework\Backup\Factory::TYPE_DB) {
             $backupManager->setRootDir($this->_filesystem->getPath(\Magento\Framework\App\Filesystem::ROOT_DIR))->addIgnorePaths($this->_backupData->getBackupIgnorePaths());
         }
         $backupManager->create();
         $message = $this->_backupData->getCreateSuccessMessageByType($type);
         $this->_logger->log($message);
     } catch (\Exception $e) {
         $this->_errors[] = $e->getMessage();
         $this->_errors[] = $e->getTrace();
         $this->_logger->log($e->getMessage(), \Zend_Log::ERR);
         $this->_logger->logException($e);
     }
     if ($this->_scopeConfig->isSetFlag(self::XML_PATH_BACKUP_MAINTENANCE_MODE, ScopeInterface::SCOPE_STORE)) {
         $this->maintenanceMode->set(false);
     }
     return $this;
 }
开发者ID:pavelnovitsky,项目名称:magento2,代码行数:35,代码来源:Observer.php

示例14: setAddress

 /**
  * {@inheritdoc}
  */
 public function setAddress($cartId, $addressData)
 {
     /** @var \Magento\Sales\Model\Quote $quote */
     $quote = $this->quoteLoader->load($cartId, $this->storeManager->getStore()->getId());
     if ($quote->isVirtual()) {
         throw new NoSuchEntityException('Cart contains virtual product(s) only. Shipping address is not applicable');
     }
     /** @var \Magento\Sales\Model\Quote\Address $address */
     $address = $this->quoteAddressFactory->create();
     $this->addressValidator->validate($addressData);
     if ($addressData->getId()) {
         $address->load($addressData->getId());
     }
     $address = $this->addressConverter->convertDataObjectToModel($addressData, $address);
     $address->setSameAsBilling(0);
     $quote->setShippingAddress($address);
     $quote->setDataChanges(true);
     try {
         $quote->save();
     } catch (\Exception $e) {
         $this->logger->logException($e);
         throw new InputException('Unable to save address. Please, check input data.');
     }
     return $quote->getShippingAddress()->getId();
 }
开发者ID:pavelnovitsky,项目名称:magento2,代码行数:28,代码来源:WriteService.php

示例15: postToConsumer

 /**
  * {@inheritdoc}
  */
 public function postToConsumer($consumerId, $endpointUrl)
 {
     try {
         $consumer = $this->_consumerFactory->create()->load($consumerId);
         if (!$consumer->getId()) {
             throw new \Magento\Framework\Oauth\Exception(__('A consumer with ID %1 does not exist', $consumerId), OauthInterface::ERR_PARAMETER_REJECTED);
         }
         $consumerData = $consumer->getData();
         $verifier = $this->_tokenFactory->create()->createVerifierToken($consumerId);
         $storeBaseUrl = $this->_storeManager->getStore()->getBaseUrl();
         $this->_httpClient->setUri($endpointUrl);
         $this->_httpClient->setParameterPost(array('oauth_consumer_key' => $consumerData['key'], 'oauth_consumer_secret' => $consumerData['secret'], 'store_base_url' => $storeBaseUrl, 'oauth_verifier' => $verifier->getVerifier()));
         $maxredirects = $this->_dataHelper->getConsumerPostMaxRedirects();
         $timeout = $this->_dataHelper->getConsumerPostTimeout();
         $this->_httpClient->setConfig(array('maxredirects' => $maxredirects, 'timeout' => $timeout));
         $this->_httpClient->request(\Magento\Framework\HTTP\ZendClient::POST);
         return $verifier->getVerifier();
     } catch (\Magento\Framework\Model\Exception $exception) {
         throw $exception;
     } catch (\Magento\Framework\Oauth\Exception $exception) {
         throw $exception;
     } catch (\Exception $exception) {
         $this->_logger->logException($exception);
         throw new \Magento\Framework\Oauth\Exception('Unable to post data to consumer due to an unexpected error');
     }
 }
开发者ID:pavelnovitsky,项目名称:magento2,代码行数:29,代码来源:Oauth.php


注:本文中的Magento\Framework\Logger类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。