当前位置: 首页>>代码示例>>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;未经允许,请勿转载。