コード例 #1
0
 /**
  * {@inheritdoc}
  */
 protected function write(array $record)
 {
     if ($this->url && !file_exists($this->url)) {
         $this->stream = null;
     }
     parent::write($record);
 }
コード例 #2
0
ファイル: PhpHandler.php プロジェクト: dongilbert/mautic
 /**
  * {@inheritdoc}
  *
  * @author Jordi Boggiano <*****@*****.**>
  */
 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);
 }
コード例 #3
0
 protected function write(array $record)
 {
     parent::write($record);
     if (is_resource($this->stream)) {
         fflush($this->stream);
     }
 }
コード例 #4
0
 protected function write(array $record)
 {
     try {
         parent::write($record);
     } catch (\UnexpectedValueException $e) {
         throw new \Exception(Filechecks::getErrorMessageMissingPermissions($this->url));
     }
 }
コード例 #5
0
ファイル: AdyenBase.php プロジェクト: pivulic/adyen-magento2
 /**
  * @{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);
 }
コード例 #6
0
 /**
  * {@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);
 }
コード例 #7
0
ファイル: Base.php プロジェクト: kidaa30/magento2-platformsh
 /**
  * @{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);
 }
コード例 #8
0
 /**
  * {@inheritdoc}
  */
 protected function write(array $record)
 {
     if (!file_exists($this->url)) {
         touch($this->url);
         // Create blank file
         chmod($this->url, 0777);
     }
     parent::write($record);
 }
コード例 #9
0
 /**
  * {@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);
 }
コード例 #10
0
 /**
  * {@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);
 }
コード例 #11
0
 /**
  * {@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);
 }
コード例 #12
0
ファイル: Html.php プロジェクト: lajosbencz/otp-simple-lib
 public function write(array $record)
 {
     $record['formatted'] .= '<br/>';
     parent::write($record);
 }
コード例 #13
0
 /**
  * @expectedException UnexpectedValueException
  */
 public function testWriteInvalidResource()
 {
     $handler = new StreamHandler('bogus://url');
     @$handler->write(array('message' => 'test'));
 }
コード例 #14
0
 /**
  * {@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);
 }