*/ class FingersCrossedFileWriter extends \TYPO3\CMS\Core\Log\Writer\FileWriter { private $recordBuffer = []; private $severityThresholdHit = FALSE; /** * Writes the log record * but only if during the request at leas tone error with severity level "error" and above ocurres * * @param LogRecord $record Log record * @return WriterInterface $this * @throws \RuntimeException */ public function writeLog(LogRecord $record) { // force at least LogLevel::ERROR otherwise accept higher levels set with $GLOBALS["TYPO3_CONF_VARS"]['SYS']['systemLogLevel'] $logLevelThreshold = $GLOBALS["TYPO3_CONF_VARS"]['SYS']['systemLogLevel'] < LogLevel::ERROR ? LogLevel::ERROR : $GLOBALS["TYPO3_CONF_VARS"]['SYS']['systemLogLevel']; if ($this->severityThresholdHit) { // write the record immediately, because the severity threshold has benn hit at least once // during this request parent::writeLog($record); } else if ($record->getLevel() <= $logLevelThreshold) { // severity level threshold hit, write all stored messages until the point the error // happend and all after $this->severityThresholdHit = TRUE; $this->recordBuffer[] = $record; foreach ($this->recordBuffer as $bufRecord) { parent::writeLog($bufRecord); } $this->recordBuffer = []; } else { // do not write immediately but store in memory $this->recordBuffer[] = $record; } return $this; } }