/**
  * Processes a log record and adds memory usage information.
  *
  * @param \TYPO3\CMS\Core\Log\LogRecord $logRecord The log record to process
  * @return \TYPO3\CMS\Core\Log\LogRecord The processed log record with additional data
  * @see memory_get_usage()
  */
 public function processLogRecord(\TYPO3\CMS\Core\Log\LogRecord $logRecord)
 {
     $bytes = memory_get_usage($this->getRealMemoryUsage());
     if ($this->formatSize) {
         $size = \TYPO3\CMS\Core\Utility\GeneralUtility::formatSize($bytes);
     } else {
         $size = $bytes;
     }
     $logRecord->addData(array('memoryUsage' => $size));
     return $logRecord;
 }
 /**
  * Add debug backtrace information to logRecord
  * It adds: filepath, line number, class and function name
  *
  * @param \TYPO3\CMS\Core\Log\LogRecord $logRecord The log record to process
  * @return \TYPO3\CMS\Core\Log\LogRecord The processed log record with additional data
  * @see debug_backtrace()
  */
 public function processLogRecord(\TYPO3\CMS\Core\Log\LogRecord $logRecord)
 {
     $trace = debug_backtrace();
     // skip first since it's always the current method
     array_shift($trace);
     // the call_user_func call is also skipped
     array_shift($trace);
     // skip TYPO3\CMS\Core\Log classes
     // @TODO: Check, if this still works. This was 't3lib_log_' before namespace switch.
     $i = 0;
     while (isset($trace[$i]['class']) && FALSE !== strpos($trace[$i]['class'], 'TYPO3\\CMS\\Core\\Log')) {
         $i++;
     }
     // we should have the call source now
     $logRecord->addData(array('file' => isset($trace[$i]['file']) ? $trace[$i]['file'] : NULL, 'line' => isset($trace[$i]['line']) ? $trace[$i]['line'] : NULL, 'class' => isset($trace[$i]['class']) ? $trace[$i]['class'] : NULL, 'function' => isset($trace[$i]['function']) ? $trace[$i]['function'] : NULL));
     return $logRecord;
 }
Beispiel #3
0
 /**
  * Add debug backtrace information to logRecord
  * It adds: filepath, line number, class and function name
  *
  * @param LogRecord $logRecord The log record to process
  * @return LogRecord The processed log record with additional data
  * @see debug_backtrace()
  */
 public function processLogRecord(LogRecord $logRecord)
 {
     $trace = $this->getDebugBacktrace();
     // skip TYPO3\CMS\Core\Log classes
     foreach ($trace as $traceEntry) {
         if (isset($traceEntry['class']) && false !== strpos($traceEntry['class'], 'TYPO3\\CMS\\Core\\Log')) {
             $trace = $this->shiftBacktraceLevel($trace);
         } else {
             break;
         }
     }
     // shift a given number of entries from the trace
     for ($i = 0; $i < $this->shiftBackTraceLevel; $i++) {
         // shift only if afterwards there is at least one entry left after.
         if (count($trace) > 1) {
             $trace = $this->shiftBacktraceLevel($trace);
         }
     }
     if ($this->appendFullBackTrace) {
         // Add the line and file of the last entry that has these information
         // to the first backtrace entry if it does not have this information.
         // This is required in case we have shifted entries and the first entry
         // is now a call_user_func that does not contain the line and file information.
         if (!isset($trace[0]['line'])) {
             $trace[0] = ['line' => $this->precedingBacktraceLine] + $trace[0];
         }
         if (!isset($trace[0]['file'])) {
             $trace[0] = ['file' => $this->precedingBacktraceFile] + $trace[0];
         }
         $logRecord->addData(['backtrace' => $trace]);
     } else {
         $logRecord->addData(['file' => isset($trace[0]['file']) ? $trace[0]['file'] : null, 'line' => isset($trace[0]['line']) ? $trace[0]['line'] : null, 'class' => isset($trace[0]['class']) ? $trace[0]['class'] : null, 'function' => isset($trace[0]['function']) ? $trace[0]['function'] : null]);
     }
     return $logRecord;
 }
Beispiel #4
0
 /**
  * Processes a log record and adds webserver environment data.
  * We use the usual "Debug System Information"
  *
  * @param \TYPO3\CMS\Core\Log\LogRecord $logRecord The log record to process
  * @return \TYPO3\CMS\Core\Log\LogRecord The processed log record with additional data
  * @see \TYPO3\CMS\Core\Utility\GeneralUtility::getIndpEnv()
  */
 public function processLogRecord(\TYPO3\CMS\Core\Log\LogRecord $logRecord)
 {
     $logRecord->addData(\TYPO3\CMS\Core\Utility\GeneralUtility::getIndpEnv('_ARRAY'));
     return $logRecord;
 }