Ejemplo n.º 1
0
 public function addDebugQuery($strSql, $exec_time, $node_id = 0)
 {
     $this->cntQuery++;
     $this->timeQuery += $exec_time;
     $this->arQueryDebug[] = $this->startSqlTracker()->getNewTrackerQuery()->setSql($strSql)->setTime($exec_time)->setTrace(defined("BX_NO_SQL_BACKTRACE") ? null : Main\Diag\Helper::getBackTrace(8, null, 2))->setState($GLOBALS["BX_STATE"])->setNode($node_id);
 }
Ejemplo n.º 2
0
 /**
  * Writes query text and part of backtrace into log file.
  *
  * @param string $sql Query to be dumped.
  * @param float $executionTime Query time.
  * @param string $additional Additional info string to be added to header.
  * @param integer $traceSkip How many backtrace frames to skip in output.
  *
  * @return void
  * @see \Bitrix\Main\Diag\SqlTracker->startFileLog
  * @see \Bitrix\Main\Diag\SqlTracker->stopFileLog
  */
 public function writeFileLog($sql, $executionTime = 0.0, $additional = "", $traceSkip = 2)
 {
     if ($this->logFilePath) {
         $header = "TIME: " . round($executionTime, 6) . " SESSION: " . session_id() . " " . $additional . "\n";
         $headerLength = strlen($header);
         $body = $this->formatSql($sql);
         $trace = $this->formatTrace(\Bitrix\Main\Diag\Helper::getBackTrace($this->depthBackTrace, null, $traceSkip));
         $footer = str_repeat("-", $headerLength);
         $message = "\n" . $header . "\n" . $body . "\n\n" . $trace . "\n" . $footer . "\n";
         \Bitrix\Main\IO\File::putFileContents($this->logFilePath, $message, \Bitrix\Main\IO\File::APPEND);
     }
 }
Ejemplo n.º 3
0
 private static function loadLazy($code, $language)
 {
     $trace = Main\Diag\Helper::getBackTrace(4, DEBUG_BACKTRACE_IGNORE_ARGS);
     $file = null;
     for ($i = 3; $i >= 1; $i--) {
         if (stripos($trace[$i]["function"], "GetMessage") === 0) {
             $file = $trace[$i]["file"];
             break;
         }
     }
     if ($file !== null && isset(self::$lazyLoadFiles[$file])) {
         self::loadLanguageFile($file, $language);
         unset(self::$lazyLoadFiles[$file]);
     } else {
         foreach (self::$lazyLoadFiles as $file) {
             self::loadLanguageFile($file, $language);
             unset(self::$lazyLoadFiles[$file]);
             if (isset(self::$messages[$language][$code])) {
                 break;
             }
         }
     }
 }
Ejemplo n.º 4
0
 private static function loadLazy($code, $language)
 {
     if ($code == '') {
         return;
     }
     $trace = Main\Diag\Helper::getBackTrace(4, DEBUG_BACKTRACE_IGNORE_ARGS);
     $currentFile = null;
     for ($i = 3; $i >= 1; $i--) {
         if (stripos($trace[$i]["function"], "GetMessage") === 0) {
             $currentFile = Path::normalize($trace[$i]["file"]);
             break;
         }
     }
     if ($currentFile !== null && isset(self::$lazyLoadFiles[$currentFile])) {
         //in most cases we know the file containing the "code" - load it directly
         self::loadLanguageFile($currentFile, $language);
         unset(self::$lazyLoadFiles[$currentFile]);
     }
     if (!isset(self::$messages[$language][$code])) {
         //we still don't know which file contains the "code" - go through the files in the reverse order
         $unset = array();
         if (($file = end(self::$lazyLoadFiles)) !== false) {
             do {
                 self::loadLanguageFile($file, $language);
                 $unset[] = $file;
                 if (isset(self::$messages[$language][$code])) {
                     if (defined("BX_MESS_LOG") && $currentFile !== null) {
                         file_put_contents(BX_MESS_LOG, 'CTranslateUtils::CopyMessage("' . $code . '", "' . $file . '", "' . $currentFile . '");' . "\n", FILE_APPEND);
                     }
                     break;
                 }
             } while (($file = prev(self::$lazyLoadFiles)) !== false);
         }
         foreach ($unset as $file) {
             unset(self::$lazyLoadFiles[$file]);
         }
     }
 }