Commit a7500926 authored by Carsten  Rose's avatar Carsten Rose
Browse files

#3768 / log to sql.log: ip, formname, feuser

Fixed
parent 4b0d1413
......@@ -374,6 +374,10 @@ class Database {
*/
private function dbLog($currentQueryMode = SQL_LOG_MODE_ALL, $sql = '', $parameterArray = array()) {
if ($sql == '') {
return;
}
$status = '';
// If no sqlLogMode is defined/available, choose SQL_LOG_MODE_ERROR
......@@ -395,25 +399,36 @@ class Database {
}
// Client IP Address
$remoteAddress = ($this->store === null) ? $this->store->getVar(CLIENT_REMOTE_ADDRESS, STORE_CLIENT) : '0.0.0.0';
$msg = '[' . date('Y.m.d H:i:s O') . '][' . $remoteAddress . ']';
$remoteAddress = ($this->store === null) ? '0.0.0.0' : $this->store->getVar(CLIENT_REMOTE_ADDRESS, STORE_CLIENT);
$logArr = [
['FE', TYPO3_FE_USER, STORE_TYPO3],
['Page', TYPO3_PAGE_ID, STORE_TYPO3],
['tt', TYPO3_TT_CONTENT_UID, STORE_TYPO3],
['level', SYSTEM_REPORT_FULL_LEVEL, STORE_SYSTEM],
['form', SIP_FORM, STORE_SIP],
];
$t3msg = '';
foreach ($logArr as $logItem) {
$value = $this->store->getVar($logItem[1], $logItem[2]);
if (!empty($value)) {
$t3msg .= $logItem[0] . ":" . $value . ",";
}
}
$t3msg = substr($t3msg, 0, strlen($t3msg) - 1);
// // FE User
// $feUser = $this->sqlLog = $this->store->getVar(TYPO3_FE_USER, STORE_TYPO3);
// $pageId = $this->sqlLog = $this->store->getVar(TYPO3_PAGE_ID, STORE_TYPO3);
// $ttcontentId = $this->sqlLog = $this->store->getVar(TYPO3_TT_CONTENT_UID, STORE_TYPO3);
$msg = '[' . date('Y.m.d H:i:s O') . '][' . $remoteAddress . '][' . $t3msg . ']';
if (count($parameterArray) > 0) {
$sql = $this->preparedStatementInsertParameter($sql, $parameterArray);
}
if ($sql !== '') {
if ($currentQueryMode == SQL_LOG_MODE_ERROR) {
$status = 'FAILED: ';
}
$msg .= '[' . $status . $sql . ']';
if ($currentQueryMode == SQL_LOG_MODE_ERROR) {
$status = 'FAILED: ';
}
$msg .= '[' . $status . $sql . ']';
Logger::logMessage($msg, $this->sqlLog);
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment