Exemplo n.º 1
0
 /**
  * Return the timeinterval since the last getLapTime().
  *
  * @return string
  */
 public function getLapTime()
 {
     $now = microtime(true);
     $elapsed = $now - $this->lap;
     $this->lap = $now;
     return \Sledgehammer\format_parsetime($elapsed) . ' sec';
 }
Exemplo n.º 2
0
 /**
  * De sql query in het debug_blok overzichtelijk weergeven
  * De keywords van een sql query dik(<b>) maken en de querytijd een kleur geven (rood voor trage queries, orange voor middelmatige en grijs voor snelle queries).
  *
  * @param string $sql
  * @param int    $truncated Number of bytes that where truncated
  * @param float  $duration
  * @param array  $backtrace
  *
  * @return string
  */
 public function renderLog($entry, $meta)
 {
     $sql = htmlspecialchars($entry, ENT_COMPAT, 'ISO-8859-15');
     static $regex = null;
     if ($regex === null) {
         $startKeywords = array('SELECT', 'UPDATE', 'ANALYSE', 'ALTER TABLE', 'REPLACE INTO', 'INSERT INTO', 'DELETE', 'CREATE TABLE', 'CREATE DATABASE', 'DESCRIBE', 'TRUNCATE TABLE', 'TRUNCATE', 'SHOW', 'SET', 'START TRANSACTION', 'ROLLBACK');
         $inlineKeywords = array('AND', 'AS', 'ASC', 'BETWEEN', 'BY', 'COLLATE', 'COLUMN', 'CURRENT_DATE', 'DESC', 'DISTINCT', 'FROM', 'GROUP', 'HAVING', 'IF', 'IN', 'INNER', 'IS', 'JOIN', 'KEY', 'LEFT', 'LIKE', 'LIMIT', 'OFFSET', 'NOT', 'NULL', 'ON', 'OR', 'ORDER', 'OUTER', 'RIGHT', 'SELECT', 'SET', 'TO', 'UNION', 'VALUES', 'WHERE');
         $regex = '/^' . implode('\\b|^', $startKeywords) . '\\b|\\b' . implode('\\b|\\b', $inlineKeywords) . '\\b/';
     }
     $sql = preg_replace($regex, '<span class="sql-keyword">\\0</span>', $sql);
     $sql = preg_replace('/`[^`]+`/', '<span class="sql-identifier">\\0</span>', $sql);
     if (isset($meta['truncated'])) {
         $kib = round($meta['truncated'] / 1024);
         $sql .= '<span class="logentry-alert">...' . $kib . ' KiB truncated</span>';
     }
     echo '<td class="logentry-code">', $sql, '</td>';
     $duration = $meta['duration'];
     if ($duration > 0.2) {
         $color = 'logentry-alert';
     } elseif ($duration > 0.05) {
         $color = 'logentry-warning';
     } else {
         $color = 'logentry-debug';
     }
     echo '<td class="logentry-number ', $color, '"><b>', \Sledgehammer\format_parsetime($duration), '</b>&nbsp;sec</td>';
 }
Exemplo n.º 3
0
 /**
  * Default renderer for a log entry (override with the $logger->renderer property).
  *
  * @param string $entry
  */
 public static function renderEntry($entry, $meta)
 {
     echo '<td>';
     if (is_array($entry)) {
         echo 'Array';
     } else {
         echo htmlspecialchars($entry, ENT_NOQUOTES, 'ISO-8859-15');
         if (isset($meta['duration'])) {
             echo '<td class="logentry-number"><b>', \Sledgehammer\format_parsetime($meta['duration']), '</b>&nbsp;sec</td>';
         }
     }
     echo '</td>';
 }