/** * Collects debug info (sql queries, errors, etc). * @param mixed $uniqueId Id of segment. * @param null $label Label for human. * @return void */ public function collectDebugInfo($uniqueId, $label = null) { if ($label === null) { $label = $uniqueId; } if ($this->exclusiveUserId !== null && $this->getUser()->getId() != $this->exclusiveUserId) { return; } if ($this->enableTimeTracker) { Debug::startTimeLabel($uniqueId); } if ($this->enableErrorHandler) { $this->prevErrorReporting = error_reporting(); error_reporting($this->levelReporting); set_error_handler(function ($code, $message, $file, $line) { if (strpos($file, '/disk/')) { $this->log(array($code, $message, $file, $line)); } }, $this->levelReporting); } if ($this->sqlBehavior & (self::SQL_COUNT | self::SQL_DETECT_LIKE | self::SQL_PRINT_ALL)) { if (empty($this->stackSql)) { $this->connection->startTracker(true); array_push($this->stackSql, array($uniqueId, 0, array())); } else { list($prevLabel, $prevLabelCount, $prevSqlTrackerQueries) = array_pop($this->stackSql); list($countQueries, $sqlTrackerQueries) = $this->getDebugInfoSql(); array_push($this->stackSql, array($prevLabel, $countQueries + $prevLabelCount, array_merge($prevSqlTrackerQueries, $sqlTrackerQueries))); $this->connection->startTracker(true); array_push($this->stackSql, array($uniqueId, 0, array())); } } }
/** * Collects debug info (sql queries, errors, etc). * @param mixed $uniqueId Id of segment. * @param null $label Label for human. * @return void */ public function collectDebugInfo($uniqueId, $label = null) { if ($label === null) { $label = $uniqueId; } if ($this->exclusiveUserId !== null && $this->getUser()->getId() != $this->exclusiveUserId) { return; } if ($this->enableTimeTracker) { Debug::startTimeLabel($uniqueId); } if ($this->enableErrorHandler) { $this->prevErrorReporting = error_reporting(); error_reporting($this->levelReporting); set_error_handler(function ($code, $message, $file, $line, $context = null) { if ($this->filePathPatternToCatchError && preg_match($this->filePathPatternToCatchError, $file)) { if (preg_match('%Non-static method C[A-Z][\\w]+::%', $message)) { //it's old style in old kernel. There aren't static in method. return; } $backtrace = debug_backtrace(); $this->log(array($code, $message, $file, $line)); } }, $this->levelReporting); } if ($this->sqlBehavior & (self::SQL_COUNT | self::SQL_DETECT_LIKE | self::SQL_PRINT_ALL)) { if (empty($this->stackSql)) { $this->connection->startTracker(true); array_push($this->stackSql, array($uniqueId, 0, array())); } else { list($prevLabel, $prevLabelCount, $prevSqlTrackerQueries) = array_pop($this->stackSql); list($countQueries, $sqlTrackerQueries) = $this->getDebugInfoSql(); array_push($this->stackSql, array($prevLabel, $countQueries + $prevLabelCount, array_merge($prevSqlTrackerQueries, $sqlTrackerQueries))); $this->connection->startTracker(true); array_push($this->stackSql, array($uniqueId, 0, array())); } } if ($this->memoryBehavior & self::MEMORY_PRINT_DIFF) { array_push($this->stackMemory, array($uniqueId, memory_get_usage(true))); } }