TYPO3 CMS  TYPO3_6-2
DatabaseWriter.php
Go to the documentation of this file.
1 <?php
3 
18 
25 
31  protected $logTable = 'sys_log';
32 
39  public function setLogTable($tableName) {
40  $this->logTable = $tableName;
41  return $this;
42  }
43 
49  public function getLogTable() {
50  return $this->logTable;
51  }
52 
60  public function writeLog(LogRecord $record) {
61  $data = '';
62  $recordData = $record->getData();
63  if (!empty($recordData)) {
64  // According to PSR3 the exception-key may hold an \Exception
65  // Since json_encode() does not encode an exception, we run the _toString() here
66  if (isset($recordData['exception']) && $recordData['exception'] instanceof \Exception) {
67  $recordData['exception'] = (string)$recordData['exception'];
68  }
69  $data = '- ' . json_encode($recordData);
70  }
71 
72  $fieldValues = array(
73  'request_id' => $record->getRequestId(),
74  'time_micro' => $record->getCreated(),
75  'component' => $record->getComponent(),
76  'level' => $record->getLevel(),
77  'message' => $record->getMessage(),
78  'data' => $data
79  );
80 
81  if (FALSE === $this->getDatabaseConnection()->exec_INSERTquery($this->logTable, $fieldValues)) {
82  throw new \RuntimeException('Could not write log record to database', 1345036334);
83  }
84  return $this;
85  }
86 
90  protected function getDatabaseConnection() {
91  return $GLOBALS['TYPO3_DB'];
92  }
93 
94 }
if(!defined('TYPO3_MODE')) $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_userauth.php']['logoff_pre_processing'][]