/**
  * Writes the log record
  *
  * @param \TYPO3\CMS\Core\Log\LogRecord $record Log record
  *
  * @return WriterInterface $this
  */
 public function writeLog(\TYPO3\CMS\Core\Log\LogRecord $record)
 {
     try {
         $this->storeLog($record->getMessage(), $record->getComponent(), $record->getLevel(), $record->getData());
     } catch (\Exception $e) {
         $this->handleExceptionDuringLogging($e);
     }
     return $this;
 }
 /**
  * Writes the log record
  *
  * @param \TYPO3\CMS\Core\Log\LogRecord $record Log record
  * @return \TYPO3\CMS\Core\Log\Writer\WriterInterface $this
  * @throws \RuntimeException
  */
 public function writeLog(\TYPO3\CMS\Core\Log\LogRecord $record)
 {
     $levelName = \TYPO3\CMS\Core\Log\LogLevel::getName($record->getLevel());
     $data = $record->getData();
     $data = !empty($data) ? '- ' . json_encode($data) : '';
     $message = sprintf('TYPO3 [%s] request="%s" component="%s": %s %s', $levelName, $record->getRequestId(), $record->getComponent(), $record->getMessage(), $data);
     if (FALSE === error_log($message)) {
         throw new \RuntimeException('Could not write log record to PHP error log', 1345036336);
     }
     return $this;
 }
 /**
  * Writes the log record
  *
  * @param \TYPO3\CMS\Core\Log\LogRecord $record Log record
  *
  * @return WriterInterface $this
  */
 public function writeLog(\TYPO3\CMS\Core\Log\LogRecord $record)
 {
     $config = \DMK\Mklog\Factory::getConfigUtility();
     // check min log level
     if (!$config->getGelfEnable() || !$config->getGelfCredentials() || $record->getLevel() > $config->getGelfMinLogLevel()) {
         return $this;
     }
     $options = \tx_rnbase::makeInstance('Tx_Rnbase_Domain_Model_Data', array('credentials' => $config->getGelfCredentials()));
     $transport = $this->getTransport();
     $transport->initialize($options);
     $message = $this->createDevlogEntry($record->getMessage(), $record->getComponent(), $record->getLevel(), $record->getData());
     try {
         $transport->publish($message);
     } catch (\Exception $e) {
         // what todo on transport exception?
         // usualy we have a emergency and a other logger (file or mail) shold take over
         return $this;
     }
     $transport->shutdown();
     return $this;
 }
 /**
  * Writes the log record
  *
  * @param LogRecord $record Log record
  * @return \TYPO3\CMS\Core\Log\Writer\WriterInterface $this
  * @throws \RuntimeException
  */
 public function writeLog(LogRecord $record)
 {
     $data = '';
     $recordData = $record->getData();
     if (!empty($recordData)) {
         // According to PSR3 the exception-key may hold an \Exception
         // Since json_encode() does not encode an exception, we run the _toString() here
         if (isset($recordData['exception']) && $recordData['exception'] instanceof \Exception) {
             $recordData['exception'] = (string) $recordData['exception'];
         }
         $data = '- ' . json_encode($recordData);
     }
     $fieldValues = array('request_id' => $record->getRequestId(), 'time_micro' => $record->getCreated(), 'component' => $record->getComponent(), 'level' => $record->getLevel(), 'message' => $record->getMessage(), 'data' => $data);
     if (false === $this->getDatabaseConnection()->exec_INSERTquery($this->logTable, $fieldValues)) {
         throw new \RuntimeException('Could not write log record to database', 1345036334);
     }
     return $this;
 }
 /**
  * Writes the log record
  *
  * @param LogRecord $record Log record
  * @return \TYPO3\CMS\Core\Log\Writer\WriterInterface $this
  * @throws \RuntimeException
  */
 public function writeLog(LogRecord $record)
 {
     $levelName = LogLevel::getName($record->getLevel());
     $data = '';
     $recordData = $record->getData();
     if (!empty($recordData)) {
         // According to PSR3 the exception-key may hold an \Exception
         // Since json_encode() does not encode an exception, we run the _toString() here
         if (isset($recordData['exception']) && $recordData['exception'] instanceof \Exception) {
             $recordData['exception'] = (string) $recordData['exception'];
         }
         $data = '- ' . json_encode($recordData);
     }
     $message = sprintf('TYPO3 [%s] request="%s" component="%s": %s %s', $levelName, $record->getRequestId(), $record->getComponent(), $record->getMessage(), $data);
     if (FALSE === error_log($message)) {
         throw new \RuntimeException('Could not write log record to PHP error log', 1345036336);
     }
     return $this;
 }
Exemple #6
0
 /**
  * Writes the log record
  *
  * @param LogRecord $record Log record
  * @return WriterInterface $this
  * @throws \RuntimeException
  */
 public function writeLog(LogRecord $record)
 {
     $timestamp = date('r', (int) $record->getCreated());
     $levelName = LogLevel::getName($record->getLevel());
     $data = '';
     $recordData = $record->getData();
     if (!empty($recordData)) {
         // According to PSR3 the exception-key may hold an \Exception
         // Since json_encode() does not encode an exception, we run the _toString() here
         if (isset($recordData['exception']) && $recordData['exception'] instanceof \Exception) {
             $recordData['exception'] = (string) $recordData['exception'];
         }
         $data = '- ' . print_r($recordData, true);
     }
     $message = sprintf('%s [%s] request="%s" component="%s": %s %s', $timestamp, $levelName, $record->getRequestId(), $record->getComponent(), $record->getMessage(), $data);
     if (false === fwrite(self::$logFileHandles[$this->logFile], $message . LF)) {
         throw new \RuntimeException('Could not write log record to log file', 1345036335);
     }
     return $this;
 }
Exemple #7
0
 /**
  * Passes the \TYPO3\CMS\Core\Log\LogRecord to all registered writers.
  *
  * @param \TYPO3\CMS\Core\Log\LogRecord $record
  * @return void
  */
 protected function writeLog(\TYPO3\CMS\Core\Log\LogRecord $record)
 {
     if (!empty($this->writers[$record->getLevel()])) {
         foreach ($this->writers[$record->getLevel()] as $writer) {
             $writer->writeLog($record);
         }
     }
 }
 /**
  * Writes the log record
  *
  * @param \TYPO3\CMS\Core\Log\LogRecord $record Log record
  * @return \TYPO3\CMS\Core\Log\Writer\WriterInterface $this
  * @throws \Exception
  */
 public function writeLog(\TYPO3\CMS\Core\Log\LogRecord $record)
 {
     $this->output->write($this->wrapMessage(vsprintf($record->getMessage(), $record->getData()), $record->getLevel()), TRUE);
 }
Exemple #9
0
 /**
  * Writes the log record to syslog
  *
  * @param LogRecord $record Log record
  * @return \TYPO3\CMS\Core\Log\Writer\WriterInterface
  * @throws \RuntimeException
  */
 public function writeLog(LogRecord $record)
 {
     if (FALSE === syslog($record->getLevel(), $this->getMessageForSyslog($record))) {
         throw new \RuntimeException('Could not write log record to syslog', 1345036337);
     }
     return $this;
 }
 /**
  * @test
  * @param \TYPO3\CMS\Core\Log\LogRecord $record Record Test Data
  * @dataProvider writerLogsToDatabaseDataProvider
  */
 public function writerLogsToDatabase(\TYPO3\CMS\Core\Log\LogRecord $record)
 {
     $logger = $this->createLogger();
     $databaseWriter = $this->createWriter();
     $logger->addWriter(\TYPO3\CMS\Core\Log\LogLevel::NOTICE, $databaseWriter);
     $this->databaseStub->expects($this->once())->method('exec_INSERTquery');
     $logger->log($record->getLevel(), $record->getMessage());
 }