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


PHP Logger::log方法代码示例

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


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

示例1: 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

示例2: 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

示例3: _processError

 /**
  * Show error as exception or log it
  *
  * @param string $errorMessage
  * @throws \Exception
  * @return void
  */
 protected function _processError($errorMessage)
 {
     if ($this->_appState->getMode() == \Magento\Framework\App\State::MODE_DEVELOPER) {
         parent::_processError($errorMessage);
     } else {
         $exception = new \Exception($errorMessage);
         $errorMessage .= $exception->getTraceAsString();
         $this->_logger->log($errorMessage, \Zend_Log::ERR);
     }
 }
开发者ID:,项目名称:,代码行数:17,代码来源:

示例4: _modifyResourceDb

 /**
  * Run module modification files. Return version of last applied upgrade (false if no upgrades applied)
  * @param string $actionType
  * @param string $fromVersion
  * @param string $toVersion
  * @return false|string
  * @throws \Magento\Framework\Exception
  */
 protected function _modifyResourceDb($actionType, $fromVersion, $toVersion)
 {
     switch ($actionType) {
         case self::TYPE_DB_INSTALL:
         case self::TYPE_DB_UPGRADE:
             $files = $this->_getAvailableDbFiles($actionType, $fromVersion, $toVersion);
             break;
         case self::TYPE_DATA_INSTALL:
         case self::TYPE_DATA_UPGRADE:
             $files = $this->_getAvailableDataFiles($actionType, $fromVersion, $toVersion);
             break;
         default:
             $files = array();
             break;
     }
     if (empty($files) || !$this->getConnection()) {
         return false;
     }
     $version = false;
     foreach ($files as $file) {
         $fileName = $file['fileName'];
         $fileType = pathinfo($fileName, PATHINFO_EXTENSION);
         $this->getConnection()->disallowDdlCache();
         try {
             switch ($fileType) {
                 case 'php':
                     $result = $this->_includeFile($fileName);
                     break;
                 case 'sql':
                     $sql = $this->modulesDir->readFile($this->modulesDir->getRelativePath($fileName));
                     if (!empty($sql)) {
                         $result = $this->run($sql);
                     } else {
                         $result = true;
                     }
                     break;
                 default:
                     $result = false;
                     break;
             }
             if ($result) {
                 $this->_setResourceVersion($actionType, $file['toVersion']);
                 $this->_logger->log($fileName);
             } else {
                 $this->_logger->log("Failed resource setup: {$fileName}");
             }
         } catch (\Exception $e) {
             throw new \Magento\Framework\Exception(sprintf('Error in file: "%s" - %s', $fileName, $e->getMessage()), 0, $e);
         }
         $version = $file['toVersion'];
         $this->getConnection()->allowDdlCache();
     }
     return $version;
 }
开发者ID:,项目名称:,代码行数:62,代码来源:

示例5: saveFile

 /**
  * Save file to storage
  *
  * @param string $filePath
  * @param string $content
  * @param bool $overwrite
  * @throws \Magento\Framework\Model\Exception
  * @return bool
  */
 public function saveFile($filePath, $content, $overwrite = false)
 {
     try {
         $directoryInstance = $this->_filesystem->getDirectoryWrite(\Magento\Framework\App\Filesystem::MEDIA_DIR);
         if (!$directoryInstance->isFile($filePath) || $overwrite && $directoryInstance->delete($filePath)) {
             $directoryInstance->writeFile($filePath, $content);
             return true;
         }
     } catch (\Magento\Framework\Filesystem\FilesystemException $e) {
         $this->_logger->log($e->getMessage());
         throw new \Magento\Framework\Model\Exception(__('Unable to save file: %1', $filePath));
     }
     return false;
 }
开发者ID:aiesh,项目名称:magento2,代码行数:23,代码来源:File.php

示例6: createPackageV1x

 /**
  * Create package file compatible with previous version of Magento Connect Manager
  *
  * @return boolean
  */
 public function createPackageV1x()
 {
     try {
         $this->writeDirectory->create('pear/');
     } catch (\Magento\Framework\Filesystem\FilesystemException $e) {
         $this->logger->addStreamLog(\Magento\Framework\Logger::LOGGER_EXCEPTION);
         $this->logger->log($e->getMessage());
         return false;
     }
     if (!$this->getPackageXml()) {
         $this->generatePackageXml();
     }
     $this->getPackage()->saveV1x($this->writeDirectory->getAbsolutePath('pear/'));
     return true;
 }
开发者ID:Atlis,项目名称:docker-magento2,代码行数:20,代码来源:Extension.php

示例7: testLogNoKey

 public function testLogNoKey()
 {
     $key = 'key';
     $this->model->log($key);
     $this->assertFalse($this->model->hasLog($key));
 }
开发者ID:,项目名称:,代码行数:6,代码来源:

示例8: _prepareDestination

 /**
  * Create destination folder if not exists and return full file path
  *
  * @param string $destination
  * @param string $newName
  * @return string
  * @throws \Exception
  */
 protected function _prepareDestination($destination = null, $newName = null)
 {
     if (empty($destination)) {
         $destination = $this->_fileSrcPath;
     } else {
         if (empty($newName)) {
             $info = pathinfo($destination);
             $newName = $info['basename'];
             $destination = $info['dirname'];
         }
     }
     if (empty($newName)) {
         $newFileName = $this->_fileSrcName;
     } else {
         $newFileName = $newName;
     }
     $fileName = $destination . '/' . $newFileName;
     if (!is_writable($destination)) {
         try {
             $this->directoryWrite->create($this->directoryWrite->getRelativePath($destination));
         } catch (\Magento\Framework\Filesystem\FilesystemException $e) {
             $this->logger->addStreamLog(\Magento\Framework\Logger::LOGGER_SYSTEM);
             $this->logger->log($e->getMessage());
             throw new \Exception('Unable to write file into directory ' . $destination . '. Access forbidden.');
         }
     }
     return $fileName;
 }
开发者ID:,项目名称:,代码行数:36,代码来源:

示例9: _getBlockInstance

 /**
  * Create block object instance based on block type
  *
  * @param string|\Magento\Framework\View\Element\AbstractBlock $block
  * @param array $attributes
  * @throws \Magento\Framework\Model\Exception
  * @return \Magento\Framework\View\Element\AbstractBlock
  */
 protected function _getBlockInstance($block, array $attributes = array())
 {
     if ($block && is_string($block)) {
         try {
             $block = $this->_blockFactory->createBlock($block, $attributes);
         } catch (\ReflectionException $e) {
             $this->_logger->log($e->getMessage());
         }
     }
     if (!$block instanceof \Magento\Framework\View\Element\AbstractBlock) {
         throw new \Magento\Framework\Model\Exception(__('Invalid block type: %1', $block));
     }
     return $block;
 }
开发者ID:,项目名称:,代码行数:22,代码来源:

示例10: _logXmlErrors

 /**
  * Log xml errors to system log
  *
  * @param string $fileName
  * @param array $libXmlErrors
  * @return void
  */
 protected function _logXmlErrors($fileName, $libXmlErrors)
 {
     $errors = array();
     if (count($libXmlErrors)) {
         foreach ($libXmlErrors as $error) {
             $errors[] = "{$error->message} Line: {$error->line}";
         }
         $this->_logger->log(sprintf("Theme layout update file '%s' is not valid.\n%s", $fileName, implode("\n", $errors)), \Zend_Log::ERR);
     }
 }
开发者ID:aiesh,项目名称:magento2,代码行数:17,代码来源:Merge.php

示例11: _logQuery

 /**
  * Log query
  *
  * @param string $sql
  * @return void
  */
 protected function _logQuery($sql)
 {
     $this->_logger->log(is_null($sql) ? $this->getSelect()->__toString() : $sql);
 }
开发者ID:,项目名称:,代码行数:10,代码来源:

示例12: _parseCgiResponse

 /**
  * Prepare shipping rate result based on response
  *
  * @param string $response
  * @return Result
  */
 protected function _parseCgiResponse($response)
 {
     $costArr = array();
     $priceArr = array();
     if (strlen(trim($response)) > 0) {
         $rRows = explode("\n", $response);
         $allowedMethods = explode(",", $this->getConfigData('allowed_methods'));
         foreach ($rRows as $rRow) {
             $row = explode('%', $rRow);
             switch (substr($row[0], -1)) {
                 case 3:
                 case 4:
                     if (in_array($row[1], $allowedMethods)) {
                         $responsePrice = $this->_localeFormat->getNumber($row[8]);
                         $costArr[$row[1]] = $responsePrice;
                         $priceArr[$row[1]] = $this->getMethodPrice($responsePrice, $row[1]);
                     }
                     break;
                 case 5:
                     $errorTitle = $row[1];
                     $message = __('Sorry, something went wrong. Please try again or contact us and we\'ll try to help.');
                     $this->_logger->log($message . ': ' . $errorTitle);
                     break;
                 case 6:
                     if (in_array($row[3], $allowedMethods)) {
                         $responsePrice = $this->_localeFormat->getNumber($row[10]);
                         $costArr[$row[3]] = $responsePrice;
                         $priceArr[$row[3]] = $this->getMethodPrice($responsePrice, $row[3]);
                     }
                     break;
                 default:
                     break;
             }
         }
         asort($priceArr);
     }
     $result = $this->_rateFactory->create();
     if (empty($priceArr)) {
         $error = $this->_rateErrorFactory->create();
         $error->setCarrier('ups');
         $error->setCarrierTitle($this->getConfigData('title'));
         $error->setErrorMessage($this->getConfigData('specificerrmsg'));
         $result->append($error);
     } else {
         foreach ($priceArr as $method => $price) {
             $rate = $this->_rateMethodFactory->create();
             $rate->setCarrier('ups');
             $rate->setCarrierTitle($this->getConfigData('title'));
             $rate->setMethod($method);
             $methodArray = $this->configHelper->getCode('method', $method);
             $rate->setMethodTitle($methodArray);
             $rate->setCost($costArr[$method]);
             $rate->setPrice($price);
             $result->append($rate);
         }
     }
     return $result;
 }
开发者ID:aiesh,项目名称:magento2,代码行数:64,代码来源:Carrier.php


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