/** * @param string $mess * @return void */ public static function debug($mess) { if (static::$debug) { \Bitrix\Main\Diag\Debug::writeToFile($mess, "", "__bx_sender_trigger.log"); } }
/** * @param $data * @return bool */ public function printToFile($data) { if (!isset($this->options['path'])) { throw new \Shantilab\BxEcho\Exceptions\EmptyFilePathException(); } if ($this->options['type'] == 'dump') { Debug::dumpToFile($data, null, $this->options['path']); } if ($this->options['type'] == 'write') { Debug::writeToFile($data, null, $this->options['path']); } }
/** * Logs debug info (sql queries, errors, etc). * @param mixed $uniqueId Id of segment. * @param null $label Label for human. * @throws SystemException * @return void */ public function logDebugInfo($uniqueId, $label = null) { if ($label === null) { $label = $uniqueId; } if ($this->exclusiveUserId !== null && $this->getUser()->getId() != $this->exclusiveUserId) { return; } $debugData = array(); if ($this->enableTimeTracker) { Debug::endTimeLabel($uniqueId); $timeLabels = Debug::getTimeLabels(); $debugData[] = "Time: {$timeLabels[$uniqueId]['time']}"; } if ($this->sqlBehavior & (self::SQL_COUNT | self::SQL_DETECT_LIKE | self::SQL_PRINT_ALL)) { list($prevLabel, $prevLabelCount, $prevSqlTrackerQueries) = array_pop($this->stackSql); list($countQueries, $sqlTrackerQueries) = $this->getDebugInfoSql(); if ($prevLabel === $uniqueId) { $countQueries += $prevLabelCount; $sqlTrackerQueries = array_merge($prevSqlTrackerQueries, $sqlTrackerQueries); } if ($this->sqlBehavior & self::SQL_COUNT) { $debugData[] = 'Count sql: ' . $countQueries; } } if ($this->sqlBehavior & (self::SQL_COUNT | self::SQL_DETECT_LIKE | self::SQL_PRINT_ALL)) { /** @var SqlTrackerQuery[] $sqlTrackerQueries */ foreach ($sqlTrackerQueries as $query) { if ($this->sqlBehavior & self::SQL_PRINT_ALL) { $debugData[] = array($query->getTime(), $query->getSql(), $this->reformatBackTrace($query->getTrace())); } if ($this->sqlBehavior & self::SQL_DETECT_LIKE && stripos($query->getSql(), 'upper') !== false) { $this->log(array('Oh... LIKE UPPER... Delete! Destroy!', $this->reformatBackTrace($query->getTrace()))); throw new SystemException('Oh... LIKE UPPER... Delete! Destroy!'); } } unset($query); } if ($this->enableErrorHandler) { error_reporting($this->prevErrorReporting); restore_error_handler(); } if ($debugData) { array_unshift($debugData, "Label: {$label}"); $this->log($debugData); } }