function getPanel() { $link = Nette\DebugHelpers::editorLink($this->sourceFile, $this->sourceLine); return '<p><b>File:</b> ' . ($link ? '<a href="' . htmlspecialchars($link) . '">' : '') . htmlspecialchars($this->sourceFile) . ($link ? '</a>' : '') . ' <b>Line:</b> ' . ($this->sourceLine ? $this->sourceLine : 'n/a') . '</p>' . ($this->sourceLine ? '<pre>' . Nette\DebugHelpers::highlightFile($this->sourceFile, $this->sourceLine) . '</pre>' : ''); }
/** * Sends message to FireLogger console. * @see http://firelogger.binaryage.com * @param mixed message to log * @return bool was successful? */ public static function fireLog($message) { if (self::$productionMode) { return; } elseif (!self::$firebugDetected || headers_sent()) { return FALSE; } static $payload = array('logs' => array()); $item = array('name' => 'PHP', 'level' => 'debug', 'order' => count($payload['logs']), 'time' => str_pad(number_format((microtime(TRUE) - self::$time) * 1000, 1, '.', ' '), 8, '0', STR_PAD_LEFT) . ' ms', 'template' => '', 'message' => '', 'style' => 'background:#767ab6'); $args = func_get_args(); if (isset($args[0]) && is_string($args[0])) { $item['template'] = array_shift($args); } if (isset($args[0]) && $args[0] instanceof \Exception) { $e = array_shift($args); $trace = $e->getTrace(); if (isset($trace[0]['class']) && $trace[0]['class'] === __CLASS__ && ($trace[0]['function'] === '_shutdownHandler' || $trace[0]['function'] === '_errorHandler')) { unset($trace[0]); } $item['exc_info'] = array($e->getMessage(), $e->getFile(), array()); $item['exc_frames'] = array(); foreach ($trace as $frame) { $frame += array('file' => NULL, 'line' => NULL, 'class' => NULL, 'type' => NULL, 'function' => NULL, 'object' => NULL, 'args' => NULL); $item['exc_info'][2][] = array($frame['file'], $frame['line'], "{$frame['class']}{$frame['type']}{$frame['function']}", $frame['object']); $item['exc_frames'][] = $frame['args']; } $file = str_replace(dirname(dirname(dirname($e->getFile()))), "…", $e->getFile()); $item['template'] = ($e instanceof \ErrorException ? '' : get_class($e) . ': ') . $e->getMessage() . ($e->getCode() ? ' #' . $e->getCode() : '') . ' in ' . $file . ':' . $e->getLine(); array_unshift($trace, array('file' => $e->getFile(), 'line' => $e->getLine())); } else { $trace = debug_backtrace(); if (isset($trace[0]['class']) && $trace[0]['class'] === __CLASS__ && ($trace[0]['function'] === '_shutdownHandler' || $trace[0]['function'] === '_errorHandler')) { unset($trace[0]); } } if (isset($args[0]) && in_array($args[0], array(self::DEBUG, self::INFO, self::WARNING, self::ERROR, self::CRITICAL), TRUE)) { $item['level'] = array_shift($args); } $item['args'] = $args; foreach ($trace as $frame) { if (isset($frame['file']) && is_file($frame['file'])) { $item['pathname'] = $frame['file']; $item['lineno'] = $frame['line']; break; } } $payload['logs'][] = DebugHelpers::jsonDump($item, -1); foreach (str_split(base64_encode(@json_encode($payload)), 4990) as $k => $v) { header("FireLogger-de11e-{$k}:{$v}"); } return TRUE; }
public function getPanel() { $s = ''; $h = 'htmlSpecialChars'; foreach ($this->queries as $i => $query) { list($sql, $params, $time, $rows, $connection, $source) = $query; $explain = NULL; // EXPLAIN is called here to work SELECT FOUND_ROWS() if ($this->explain && preg_match('#\\s*SELECT\\s#iA', $sql)) { try { $explain = $connection->queryArgs('EXPLAIN ' . $sql, $params)->fetchAll(); } catch (\PDOException $e) { } } $s .= '<tr><td>' . sprintf('%0.3f', $time * 1000); if ($explain) { $s .= "<br /><a href='#' class='nette-toggler' rel='#nette-debug-database-row-{$h($this->name)}-{$i}'>explain ►</a>"; } $s .= '</td><td class="database-sql">' . Connection::highlightSql(Nette\String::truncate($sql, self::$maxLength)); if ($explain) { $s .= "<table id='nette-debug-database-row-{$h($this->name)}-{$i}' class='nette-collapsed'><tr>"; foreach ($explain[0] as $col => $foo) { $s .= "<th>{$h($col)}</th>"; } $s .= "</tr>"; foreach ($explain as $row) { $s .= "<tr>"; foreach ($row as $col) { $s .= "<td>{$h($col)}</td>"; } $s .= "</tr>"; } $s .= "</table>"; } if ($source) { list($file, $line) = $source; $s .= (Nette\Debug::$editor ? "<a href='{$h(Nette\DebugHelpers::editorLink($file, $line))}'" : '<span') . " class='database-source' title='{$h($file)}:{$line}'>" . "{$h(basename(dirname($file)) . '/' . basename($file))}:{$line}" . (Nette\Debug::$editor ? '</a>' : '</span>'); } $s .= '</td><td>'; foreach ($params as $param) { $s .= "{$h(Nette\String::truncate($param, self::$maxLength))}<br>"; } $s .= '</td><td>' . $rows . '</td></tr>'; } return empty($this->queries) ? '' : '<style> #nette-debug-database td.database-sql { background: white !important } #nette-debug-database .database-source { color: #BBB !important } #nette-debug-database tr table { margin: 8px 0; max-height: 150px; overflow:auto } </style> <h1>Queries: ' . count($this->queries) . ($this->totalTime ? ', time: ' . sprintf('%0.3f', $this->totalTime * 1000) . ' ms' : '') . '</h1> <div class="nette-inner"> <table> <tr><th>Time ms</th><th>SQL Statement</th><th>Params</th><th>Rows</th></tr>' . $s . ' </table> </div>'; }