TYPO3 CMS  TYPO3_6-2
PhpErrorLogWriter.php
Go to the documentation of this file.
1 <?php
3 
19 
27 
35  public function writeLog(LogRecord $record) {
36  $levelName = LogLevel::getName($record->getLevel());
37  $data = '';
38  $recordData = $record->getData();
39  if (!empty($recordData)) {
40  // According to PSR3 the exception-key may hold an \Exception
41  // Since json_encode() does not encode an exception, we run the _toString() here
42  if (isset($recordData['exception']) && $recordData['exception'] instanceof \Exception) {
43  $recordData['exception'] = (string)$recordData['exception'];
44  }
45  $data = '- ' . json_encode($recordData);
46  }
47  $message = sprintf(
48  'TYPO3 [%s] request="%s" component="%s": %s %s',
49  $levelName,
50  $record->getRequestId(),
51  $record->getComponent(),
52  $record->getMessage(),
53  $data
54  );
55  if (FALSE === error_log($message)) {
56  throw new \RuntimeException('Could not write log record to PHP error log', 1345036336);
57  }
58  return $this;
59  }
60 
61 }
static getName($level)
Definition: LogLevel.php:111