/**
  * {@inheritdoc}
  */
 protected function write(array $record)
 {
     if ($this->url && !file_exists($this->url)) {
         $this->stream = null;
     }
     parent::write($record);
 }
示例#2
0
 /**
  * {@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);
 }
 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
 /**
  * @{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);
 }
 /**
  * {@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
 /**
  * @{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);
 }
 /**
  * {@inheritdoc}
  */
 protected function write(array $record)
 {
     if (!file_exists($this->url)) {
         touch($this->url);
         // Create blank file
         chmod($this->url, 0777);
     }
     parent::write($record);
 }
 /**
  * {@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);
 }
 /**
  * {@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
 public function write(array $record)
 {
     $record['formatted'] .= '<br/>';
     parent::write($record);
 }
 /**
  * @expectedException UnexpectedValueException
  */
 public function testWriteInvalidResource()
 {
     $handler = new StreamHandler('bogus://url');
     @$handler->write(array('message' => 'test'));
 }
 /**
  * {@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);
 }