Ejemplo n.º 1
0
 /**
  * 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;
 }
Ejemplo n.º 2
0
 /**
  * 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;
 }
Ejemplo n.º 3
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;
 }
Ejemplo n.º 4
0
 /**
  * Convert record to string for simple output, like echo().
  * Contents of data array is appended as JSON-encoded string
  *
  * @return string
  */
 public function __toString()
 {
     $timestamp = date('r', (int) $this->created);
     $levelName = \TYPO3\CMS\Core\Log\LogLevel::getName($this->level);
     $data = !empty($this->data) ? '- ' . json_encode($this->data) : '';
     $logRecordString = sprintf('%s [%s] request="%s" component="%s": %s %s', $timestamp, $levelName, $this->requestId, $this->component, $this->message, $data);
     return $logRecordString;
 }
Ejemplo n.º 5
0
 /**
  * Convert record to string for simple output, like echo().
  * Contents of data array is appended as JSON-encoded string
  *
  * @return string
  */
 public function __toString()
 {
     $timestamp = date('r', (int) $this->created);
     $levelName = LogLevel::getName($this->level);
     $data = '';
     if (!empty($this->data)) {
         // 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($this->data['exception']) && $this->data['exception'] instanceof \Exception) {
             $this->data['exception'] = (string) $this->data['exception'];
         }
         $data = '- ' . json_encode($this->data);
     }
     $logRecordString = sprintf('%s [%s] request="%s" component="%s": %s %s', $timestamp, $levelName, $this->requestId, $this->component, $this->message, $data);
     return $logRecordString;
 }