當前位置: 首頁>>代碼示例>>PHP>>正文


PHP StreamHandler::write方法代碼示例

本文整理匯總了PHP中Monolog\Handler\StreamHandler::write方法的典型用法代碼示例。如果您正苦於以下問題:PHP StreamHandler::write方法的具體用法?PHP StreamHandler::write怎麽用?PHP StreamHandler::write使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Monolog\Handler\StreamHandler的用法示例。


在下文中一共展示了StreamHandler::write方法的14個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: write

 /**
  * {@inheritdoc}
  */
 protected function write(array $record)
 {
     if ($this->url && !file_exists($this->url)) {
         $this->stream = null;
     }
     parent::write($record);
 }
開發者ID:kamilsk,項目名稱:common,代碼行數:10,代碼來源:BulletproofStreamHandler.php

示例2: write

 /**
  * {@inheritdoc}
  *
  * @author Jordi Boggiano <j.boggiano@seld.be>
  */
 protected function write(array $record)
 {
     //check to see if the resource has anything written to it
     if (!is_resource($this->stream)) {
         if (!$this->url) {
             throw new \LogicException('Missing stream url, the stream can not be opened. This may be caused by a premature call to close().');
         }
         $this->errorMessage = null;
         set_error_handler([$this, 'customErrorHandler']);
         if (!file_exists($this->url)) {
             $this->stream = fopen($this->url, 'a');
             //write php line to it
             fwrite($this->stream, (string) '<?php die("access denied!"); ?>' . "\n\n");
         } else {
             $this->stream = fopen($this->url, 'a');
         }
         if ($this->filePermission !== null) {
             @chmod($this->url, $this->filePermission);
         }
         restore_error_handler();
         if (!is_resource($this->stream)) {
             $this->stream = null;
             throw new \UnexpectedValueException(sprintf('The stream or file "%s" could not be opened: ' . $this->errorMessage, $this->url));
         }
     }
     parent::write($record);
 }
開發者ID:dongilbert,項目名稱:mautic,代碼行數:32,代碼來源:PhpHandler.php

示例3: write

 protected function write(array $record)
 {
     parent::write($record);
     if (is_resource($this->stream)) {
         fflush($this->stream);
     }
 }
開發者ID:VasekPurchart,項目名稱:khanovaskola-v3,代碼行數:7,代碼來源:FlushingStreamHandler.php

示例4: write

 protected function write(array $record)
 {
     try {
         parent::write($record);
     } catch (\UnexpectedValueException $e) {
         throw new \Exception(Filechecks::getErrorMessageMissingPermissions($this->url));
     }
 }
開發者ID:FluentDevelopment,項目名稱:piwik,代碼行數:8,代碼來源:FileHandler.php

示例5: write

 /**
  * @{inheritDoc}
  *
  * @param $record array
  * @return void
  */
 public function write(array $record)
 {
     $logDir = $this->filesystem->getParentDirectory($this->url);
     if (!$this->filesystem->isDirectory($logDir)) {
         $this->filesystem->createDirectory($logDir, 0777);
     }
     parent::write($record);
 }
開發者ID:pivulic,項目名稱:adyen-magento2,代碼行數:14,代碼來源:AdyenBase.php

示例6: write

 /**
  * {@inheritdoc}
  */
 public function write(array $record)
 {
     // on the first record written, if the log is new, we should rotate (once per day)
     if (null === $this->mustRotate) {
         $this->mustRotate = !file_exists($this->url);
     }
     return parent::write($record);
 }
開發者ID:nickaggarwal,項目名稱:sample-symfony2,代碼行數:11,代碼來源:RotatingFileHandler.php

示例7: write

 /**
  * @{inheritDoc}
  *
  * @param $record array
  * @return void
  */
 public function write(array $record)
 {
     $logDir = $this->filesystem->getParentDirectory($this->url);
     if (!$this->filesystem->isDirectory($logDir)) {
         $this->filesystem->createDirectory($logDir, DriverInterface::WRITEABLE_DIRECTORY_MODE);
     }
     parent::write($record);
 }
開發者ID:kidaa30,項目名稱:magento2-platformsh,代碼行數:14,代碼來源:Base.php

示例8: write

 /**
  * {@inheritdoc}
  */
 protected function write(array $record)
 {
     if (!file_exists($this->url)) {
         touch($this->url);
         // Create blank file
         chmod($this->url, 0777);
     }
     parent::write($record);
 }
開發者ID:quyenminh102,項目名稱:flywheel-framework,代碼行數:12,代碼來源:StreamHandler.php

示例9: write

 /**
  * {@inheritdoc}
  */
 public function write(array $record)
 {
     if (!$this->url) {
         $this->url = $this->getRealPath($this->generateLogFilename());
     }
     if (!is_dir(dirname($this->url))) {
         mkdir(dirname($this->url), 0755, true);
     }
     parent::write($record);
 }
開發者ID:ashutosh-srijan,項目名稱:findit_akeneo,代碼行數:13,代碼來源:BatchLogHandler.php

示例10: write

 /**
  * {@inheritdoc}
  */
 protected function write(array $record)
 {
     // on the first record written, if the log is new, we should rotate (once per day)
     if (null === $this->mustRotate) {
         $this->mustRotate = !file_exists($this->url);
     }
     if ($this->nextRotation < $record['datetime']) {
         $this->mustRotate = true;
         $this->close();
     }
     parent::write($record);
 }
開發者ID:Laxman-SM,項目名稱:iron_worker_examples,代碼行數:15,代碼來源:RotatingFileHandler.php

示例11: write

 /**
  * {@inheritDoc}
  *
  * If the file does not exist, it is created with 0777 permissions.
  */
 public function write(array $record)
 {
     if (null === $this->stream) {
         // From original monolog stream handler
         if (!$this->url) {
             throw new \LogicException('Missing stream url, the stream can not be opened. This may be caused by a premature call to close().');
         }
         // Make the directory, if it doesn't exist
         $dir = dirname($this->url);
         if (!is_dir($dir)) {
             mkdir($dir, 0777, true);
         }
         // Make the file, if it doesn't exist
         if (!file_exists($this->url)) {
             if (touch($this->url)) {
                 chmod($this->url, 0777);
             }
         }
     }
     return parent::write($record);
 }
開發者ID:mothership-ec,項目名稱:cog,代碼行數:26,代碼來源:TouchingStreamHandler.php

示例12: write

 public function write(array $record)
 {
     $record['formatted'] .= '<br/>';
     parent::write($record);
 }
開發者ID:lajosbencz,項目名稱:otp-simple-lib,代碼行數:5,代碼來源:Html.php

示例13: testWriteInvalidResource

 /**
  * @expectedException UnexpectedValueException
  */
 public function testWriteInvalidResource()
 {
     $handler = new StreamHandler('bogus://url');
     @$handler->write(array('message' => 'test'));
 }
開發者ID:nickaggarwal,項目名稱:sample-symfony2,代碼行數:8,代碼來源:StreamHandlerTest.php

示例14: write

 /**
  * {@inheritdoc}
  */
 public function write(array $record)
 {
     $this->currentTimestamp = $record['datetime'];
     if (null === $this->mustRotate) {
         $this->mustRotate = !file_exists($this->url);
         $this->nextRotation = $this->nextRotationTime($this->currentTimestamp);
     }
     if ($this->nextRotation < $this->currentTimestamp) {
         $this->mustRotate = true;
         $this->close();
     }
     parent::write($record);
 }
開發者ID:haymetric,項目名稱:haymetric-sdk-php,代碼行數:16,代碼來源:HaymetricStreamHandler.php


注:本文中的Monolog\Handler\StreamHandler::write方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。