Skip to content

Commit

Permalink
BlueScreen: added $maxDepth & $maxLength [Closes #114]
Browse files Browse the repository at this point in the history
  • Loading branch information
dg committed Jun 16, 2016
1 parent 12d5caf commit e79e3dd
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 9 deletions.
14 changes: 14 additions & 0 deletions src/Tracy/BlueScreen.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,12 @@ class BlueScreen
/** @var string[] paths to be collapsed in stack trace (e.g. core libraries) */
public $collapsePaths = [];

/** @var int */
public $maxDepth = 3;

/** @var int */
public $maxLength = 150;


public function __construct()
{
Expand Down Expand Up @@ -98,6 +104,14 @@ private function renderTemplate($exception, $template)
? $source . (strpos($source, '?') ? '&' : '?') . '_tracy_skip_error'
: NULL;
$lastError = $exception instanceof \ErrorException || $exception instanceof \Error ? NULL : error_get_last();
$dump = function($v) {
return Dumper::toHtml($v, [
Dumper::DEPTH => $this->maxDepth,
Dumper::TRUNCATE => $this->maxLength,
Dumper::LIVE => TRUE,
Dumper::LOCATION => Dumper::LOCATION_CLASS,
]);
};

require $template;
}
Expand Down
19 changes: 10 additions & 9 deletions src/Tracy/assets/BlueScreen/content.phtml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
* @param bool $sourceIsUrl
* @param string $skipError
* @param array $lastError
* @param callable $dump
* @return void
*/

Expand Down Expand Up @@ -116,7 +117,7 @@ $code = $exception->getCode() ? ' #' . $exception->getCode() : '';
<?php endif ?>

<?php if (isset($row['object'])): ?>
<div class="tracy-collapsed outer object"><?= Dumper::toHtml($row['object'], [Dumper::LIVE => TRUE]) ?></div>
<div class="tracy-collapsed outer object"><?= $dump($row['object']) ?></div>
<?php endif ?>

<?php if (!empty($row['args'])): ?>
Expand All @@ -131,7 +132,7 @@ $code = $exception->getCode() ? ' #' . $exception->getCode() : '';
}
foreach ($row['args'] as $k => $v) {
echo '<tr><th>', Helpers::escapeHtml(isset($params[$k]) ? '$' . $params[$k]->name : "#$k"), '</th><td>';
echo Dumper::toHtml($v, [Dumper::LOCATION => Dumper::LOCATION_CLASS, Dumper::LIVE => TRUE]);
echo $dump($v);
echo "</td></tr>\n";
}
?>
Expand All @@ -154,7 +155,7 @@ $code = $exception->getCode() ? ' #' . $exception->getCode() : '';
<table>
<?php
foreach ($ex->context as $k => $v) {
echo '<tr><th>$', Helpers::escapeHtml($k), '</th><td>', Dumper::toHtml($v, [Dumper::LOCATION => Dumper::LOCATION_CLASS, Dumper::LIVE => TRUE]), "</td></tr>\n";
echo '<tr><th>$', Helpers::escapeHtml($k), '</th><td>', $dump($v), "</td></tr>\n";
}
?>
</table>
Expand All @@ -170,7 +171,7 @@ $code = $exception->getCode() ? ' #' . $exception->getCode() : '';
<div class="panel">
<h2><a data-tracy-ref="^+" class="tracy-toggle tracy-collapsed">Exception</a></h2>
<div class="tracy-collapsed inner">
<?= Dumper::toHtml($exception, [Dumper::LOCATION => Dumper::LOCATION_CLASS, Dumper::LIVE => TRUE]) ?>
<?= $dump($exception) ?>
</div></div>
<?php endif ?>

Expand Down Expand Up @@ -213,7 +214,7 @@ $code = $exception->getCode() ? ' #' . $exception->getCode() : '';
<div class="outer">
<table>
<?php
foreach ($_SERVER as $k => $v) echo '<tr><th>', Helpers::escapeHtml($k), '</th><td>', Dumper::toHtml($v), "</td></tr>\n";
foreach ($_SERVER as $k => $v) echo '<tr><th>', Helpers::escapeHtml($k), '</th><td>', $dump($v), "</td></tr>\n";
?>
</table>
</div>
Expand All @@ -226,7 +227,7 @@ $code = $exception->getCode() ? ' #' . $exception->getCode() : '';
<?php else: ?>
<table>
<?php
foreach ($_SESSION as $k => $v) echo '<tr><th>', Helpers::escapeHtml($k), '</th><td>', $k === '__NF' ? '<i>Nette Session</i>' : Dumper::toHtml($v, [Dumper::LOCATION => Dumper::LOCATION_CLASS, Dumper::LIVE => TRUE]), "</td></tr>\n";
foreach ($_SESSION as $k => $v) echo '<tr><th>', Helpers::escapeHtml($k), '</th><td>', $k === '__NF' ? '<i>Nette Session</i>' : $dump($v), "</td></tr>\n";
?>
</table>
<?php endif ?>
Expand All @@ -238,7 +239,7 @@ $code = $exception->getCode() ? ' #' . $exception->getCode() : '';
<div class="outer">
<table>
<?php
foreach ($_SESSION['__NF']['DATA'] as $k => $v) echo '<tr><th>', Helpers::escapeHtml($k), '</th><td>', Dumper::toHtml($v, [Dumper::LOCATION => Dumper::LOCATION_CLASS, Dumper::LIVE => TRUE]), "</td></tr>\n";
foreach ($_SESSION['__NF']['DATA'] as $k => $v) echo '<tr><th>', Helpers::escapeHtml($k), '</th><td>', $dump($v), "</td></tr>\n";
?>
</table>
</div>
Expand All @@ -254,7 +255,7 @@ $code = $exception->getCode() ? ' #' . $exception->getCode() : '';
<?php
foreach ($list['user'] as $k => $v) {
echo '<tr><th>', Helpers::escapeHtml($k), '</th>';
echo '<td>', Dumper::toHtml($v), "</td></tr>\n";
echo '<td>', $dump($v), "</td></tr>\n";
}
?>
</table>
Expand Down Expand Up @@ -293,7 +294,7 @@ $code = $exception->getCode() ? ' #' . $exception->getCode() : '';
<div class="outer">
<table>
<?php
foreach ($GLOBALS[$name] as $k => $v) echo '<tr><th>', Helpers::escapeHtml($k), '</th><td>', Dumper::toHtml($v), "</td></tr>\n";
foreach ($GLOBALS[$name] as $k => $v) echo '<tr><th>', Helpers::escapeHtml($k), '</th><td>', $dump($v), "</td></tr>\n";
?>
</table>
</div>
Expand Down

0 comments on commit e79e3dd

Please sign in to comment.