Permalink
Browse files

Custom paths can be configured as collapsed in bluescreen

  • Loading branch information...
1 parent 17d0fba commit cc025ff0f956b03c0f696f8bdb8b63d1a7744a5b @juzna committed Jan 31, 2012
@@ -23,10 +23,18 @@
*/
class BlueScreen extends Nette\Object
{
+ /** @var array Path to be collapsed in stack trace (e.g. core libraries) */
+ public $collapsePaths = array();
+
/** @var array */
private $panels = array();
+ public function __construct()
+ {
+ $this->collapsePaths[] = NETTE_DIR . DIRECTORY_SEPARATOR; // . 'Utils' . DIRECTORY_SEPARATOR . 'Object';
+ }
+
/**
* Add custom panel.
@@ -219,4 +219,19 @@ public static function findTrace(array $trace, $method, & $index = NULL)
}
}
+
+ /**
+ * Should a file be collapsed in stack trace?
+ * @param BlueScreen
+ * @param string
+ * @return bool
+ */
+ public static function isCollapsed(BlueScreen $bluescreen, $file)
+ {
+ foreach($bluescreen->collapsePaths as $collapsePath) {
+ if(strpos($file, $collapsePath) === 0) return true;
+ }
+
+ return false;
+ }
}
@@ -40,7 +40,6 @@ static $errorTypes = array(
$title = ($exception instanceof Nette\FatalErrorException && isset($errorTypes[$exception->getSeverity()])) ? $errorTypes[$exception->getSeverity()] : get_class($exception);
-$expandPath = NETTE_DIR . DIRECTORY_SEPARATOR; // . 'Utils' . DIRECTORY_SEPARATOR . 'Object';
$counter = 0;
?><!DOCTYPE html><!-- "' --></script></style></pre></xmp></table>
@@ -323,9 +322,9 @@ $counter = 0;
<?php $stack = $ex->getTrace(); $expanded = NULL ?>
- <?php if (strpos($ex->getFile(), $expandPath) === 0) {
+ <?php if (Helpers::isCollapsed($this, $ex->getFile()) ) {
foreach ($stack as $key => $row) {
- if (isset($row['file']) && strpos($row['file'], $expandPath) !== 0) { $expanded = $key; break; }
+ if (isset($row['file']) && !Helpers::isCollapsed($this, $row['file'])) { $expanded = $key; break; }
}
} ?>
@@ -0,0 +1,26 @@
+<?php
+
+/**
+ * Test: Nette\Diagnostics\Debugger E_ERROR in console.
+ *
+ * @author David Grudl
+ * @package Nette\Diagnostics
+ * @subpackage UnitTests
+ */
+
+use Nette\Diagnostics\Debugger,
+ \Nette\Diagnostics\Helpers;
+
+
+
+require __DIR__ . '/../bootstrap.php';
+
+
+
+Debugger::$consoleMode = TRUE;
+Debugger::$productionMode = FALSE;
+
+Debugger::$blueScreen->collapsePaths[] = __DIR__;
+
+Assert::true(Helpers::isCollapsed(Debugger::$blueScreen, __FILE__));
+Assert::false(Helpers::isCollapsed(Debugger::$blueScreen, dirname(__DIR__) . '/somethingElse'));

0 comments on commit cc025ff

Please sign in to comment.