Ejemplo n.º 1
1
 /**
  * @param \Doctrine\Common\Annotations\AnnotationException $e
  *
  * @return string
  */
 public static function highlightAnnotationLine(AnnotationException $e)
 {
     foreach ($e->getTrace() as $step) {
         if (@$step['class'] . @$step['type'] . @$step['function'] !== 'Doctrine\\Common\\Annotations\\DocParser->parse') {
             continue;
         }
         $context = Strings::match($step['args'][1], '~^(?P<type>[^\\s]+)\\s*(?P<class>[^:]+)(?:::\\$?(?P<property>[^\\(]+))?$~i');
         break;
     }
     if (!isset($context)) {
         return FALSE;
     }
     $refl = Nette\Reflection\ClassType::from($context['class']);
     $file = $refl->getFileName();
     $line = NULL;
     if ($context['type'] === 'property') {
         $refl = $refl->getProperty($context['property']);
         $line = Kdyby\Doctrine\Helpers::getPropertyLine($refl);
     } elseif ($context['type'] === 'method') {
         $refl = $refl->getProperty($context['method']);
     }
     if (($errorLine = self::calculateErrorLine($refl, $e, $line)) === NULL) {
         return FALSE;
     }
     $dump = BlueScreen::highlightFile($file, $errorLine);
     return '<p><b>File:</b> ' . self::editorLink($file, $errorLine) . '</p>' . $dump;
 }
Ejemplo n.º 2
0
 /**
  * @return BlueScreen
  */
 public function create()
 {
     $blueScreen = new BlueScreen();
     $blueScreen->info = $this->info;
     foreach ($this->panels as $panel) {
         $blueScreen->addPanel($panel);
     }
     $blueScreen->collapsePaths = $this->collapsePaths;
     return $blueScreen;
 }
 public static function onException($exception)
 {
     ob_start();
     // double buffer prevents sending HTTP headers in some PHP
     ob_start();
     $bs = new BlueScreen();
     $bs->render($exception);
     $report = ob_get_contents();
     ob_end_clean();
     ob_end_clean();
     self::saveReport($exception->getMessage(), $report);
 }
Ejemplo n.º 4
0
 public static function initialize()
 {
     $blueScreen = Tracy\Debugger::getBlueScreen();
     if (preg_match('#(.+)/Bridges/Framework$#', strtr(__DIR__, '\\', '/'), $m)) {
         if (preg_match('#(.+)/nette/bootstrap/src$#', $m[1], $m2)) {
             $blueScreen->collapsePaths[] = "{$m2['1']}/nette";
             $blueScreen->collapsePaths[] = "{$m2['1']}/latte";
         } else {
             $blueScreen->collapsePaths[] = $m[1];
         }
     }
     if (class_exists('Nette\\Framework')) {
         $bar = Tracy\Debugger::getBar();
         $bar->info[] = $blueScreen->info[] = 'Nette Framework ' . Nette\Framework::VERSION . ' (' . Nette\Framework::REVISION . ')';
     }
     $blueScreen->addPanel(function ($e) {
         if ($e instanceof Latte\CompileException) {
             return array('tab' => 'Template', 'panel' => '<p>' . (is_file($e->sourceName) ? '<b>File:</b> ' . Helpers::editorLink($e->sourceName, $e->sourceLine) : htmlspecialchars($e->sourceName)) . '</p>' . ($e->sourceCode ? '<pre>' . BlueScreen::highlightLine(htmlspecialchars($e->sourceCode), $e->sourceLine) . '</pre>' : ''));
         } elseif ($e instanceof Nette\Neon\Exception && preg_match('#line (\\d+)#', $e->getMessage(), $m)) {
             if ($item = Helpers::findTrace($e->getTrace(), 'Nette\\DI\\Config\\Adapters\\NeonAdapter::load')) {
                 return array('tab' => 'NEON', 'panel' => '<p><b>File:</b> ' . Helpers::editorLink($item['args'][0], $m[1]) . '</p>' . BlueScreen::highlightFile($item['args'][0], $m[1]));
             } elseif ($item = Helpers::findTrace($e->getTrace(), 'Nette\\Neon\\Decoder::decode')) {
                 return array('tab' => 'NEON', 'panel' => BlueScreen::highlightPhp($item['args'][0], $m[1]));
             }
         }
     });
 }
Ejemplo n.º 5
0
 /**
  * @param \Kdyby\Autowired\Exception $e
  * @return string
  */
 protected static function highlightException(Kdyby\Autowired\Exception $e)
 {
     $refl = $e->getReflector();
     /** @var \Reflector|\Nette\Reflection\Property|\Nette\Reflection\Method $refl */
     $file = $refl->getDeclaringClass()->getFileName();
     $line = $refl instanceof Nette\Reflection\Property ? self::getPropertyLine($refl) : $refl->getStartLine();
     return '<p><b>File:</b> ' . Helpers::editorLink($file, $line) . '</p>' . BlueScreen::highlightFile($file, $line);
 }
 /**
  * @author David Grudl
  * @see    https://github.com/nette/tracy
  */
 protected function logException(Throwable $exception) : array
 {
     $file = $this->getExceptionFile($exception);
     if ($handle = @fopen($file, 'x')) {
         // @ file may already exist
         ob_start();
         // double buffer prevents sending HTTP headers in some PHP
         ob_start(function ($buffer) use($handle) {
             fwrite($handle, $buffer);
         }, 4096);
         $this->blueScreen->render($exception);
         ob_end_flush();
         ob_end_clean();
         fclose($handle);
         return [true, $file];
     } else {
         return [false, $file];
     }
 }
Ejemplo n.º 7
0
 /**
  * Renders blue screen.
  *
  * @param  \Exception|\Throwable
  *
  * @return void
  */
 public function render($exception)
 {
     if (isset($this->sslAuthorizedDn['emailAddress']) && !in_array($this->sslAuthorizedDn['emailAddress'], $this->logIgnoreEmail) && in_array($this->siteMode, ['public', 'ssd'])) {
         if ($exception instanceof \ErrorException) {
             $severity = $exception->getSeverity();
             Debugger::getLogger()->log($exception, ($severity & Debugger::$logSeverity) === $severity ? Tracy\ILogger::ERROR : Tracy\ILogger::EXCEPTION);
         } else {
             Debugger::getLogger()->log($exception, Tracy\ILogger::EXCEPTION);
         }
     }
     parent::render($exception);
 }
Ejemplo n.º 8
0
 public static function initialize()
 {
     $blueScreen = Tracy\Debugger::getBlueScreen();
     if (class_exists('Nette\\Framework')) {
         $version = Framework::VERSION . (Framework::REVISION ? ' (' . Framework::REVISION . ')' : '');
         Tracy\Debugger::getBar()->getPanel('Tracy:info')->data['Nette Framework'] = $version;
         $blueScreen->info[] = "Nette Framework {$version}";
     }
     $blueScreen->addPanel(function ($e) {
         if ($e instanceof Latte\CompileException) {
             return ['tab' => 'Template', 'panel' => (@is_file($e->sourceName) ? '<p><b>File:</b> ' . Helpers::editorLink($e->sourceName, $e->sourceLine) . '</p>' : '') . '<pre>' . BlueScreen::highlightLine(htmlspecialchars($e->sourceCode, ENT_IGNORE, 'UTF-8'), $e->sourceLine) . '</pre>'];
         }
     });
     $blueScreen->addPanel(function ($e) {
         if ($e instanceof Nette\Neon\Exception && preg_match('#line (\\d+)#', $e->getMessage(), $m) && ($trace = Helpers::findTrace($e->getTrace(), 'Nette\\Neon\\Decoder::decode'))) {
             return ['tab' => 'NEON', 'panel' => ($trace2 = Helpers::findTrace($e->getTrace(), 'Nette\\DI\\Config\\Adapters\\NeonAdapter::load')) ? '<p><b>File:</b> ' . Helpers::editorLink($trace2['args'][0], $m[1]) . '</p>' . BlueScreen::highlightFile($trace2['args'][0], $m[1]) : BlueScreen::highlightPhp($trace['args'][0], $m[1])];
         }
     });
 }
Ejemplo n.º 9
0
 public static function initialize()
 {
     $bar = Tracy\Debugger::getBar();
     $bar->info[] = 'Nette Framework ' . Nette\Framework::VERSION . ' (' . substr(Nette\Framework::REVISION, 8) . ')';
     $blueScreen = Tracy\Debugger::getBlueScreen();
     $blueScreen->collapsePaths[] = dirname(dirname(__DIR__));
     $blueScreen->info[] = 'Nette Framework ' . Nette\Framework::VERSION . ' (revision ' . Nette\Framework::REVISION . ')';
     $blueScreen->addPanel(function ($e) {
         if ($e instanceof Latte\CompileException) {
             return array('tab' => 'Template', 'panel' => '<p>' . (is_file($e->sourceName) ? '<b>File:</b> ' . Helpers::editorLink($e->sourceName, $e->sourceLine) : htmlspecialchars($e->sourceName)) . '</p>' . ($e->sourceCode ? '<pre>' . BlueScreen::highlightLine(htmlspecialchars($e->sourceCode), $e->sourceLine) . '</pre>' : ''));
         } elseif ($e instanceof Nette\Utils\NeonException && preg_match('#line (\\d+)#', $e->getMessage(), $m)) {
             if ($item = Helpers::findTrace($e->getTrace(), 'Nette\\DI\\Config\\Adapters\\NeonAdapter::load')) {
                 return array('tab' => 'NEON', 'panel' => '<p><b>File:</b> ' . Helpers::editorLink($item['args'][0], $m[1]) . '</p>' . BlueScreen::highlightFile($item['args'][0], $m[1]));
             } elseif ($item = Helpers::findTrace($e->getTrace(), 'Nette\\Utils\\Neon::decode')) {
                 return array('tab' => 'NEON', 'panel' => BlueScreen::highlightPhp($item['args'][0], $m[1]));
             }
         }
     });
 }
Ejemplo n.º 10
0
 public static function renderException($e = NULL)
 {
     if (!$e instanceof InvalidResourceException || !($previous = $e->getPrevious())) {
         return NULL;
     }
     $previous = $previous->getPrevious();
     if (!$previous instanceof Yaml\Exception\ParseException) {
         return NULL;
     }
     $method = 'Symfony\\Component\\Translation\\Loader\\YamlFileLoader::load';
     if ($call = Helpers::findTrace($e->getPrevious()->getTrace(), $method)) {
         return array('tab' => 'YAML dictionary', 'panel' => '<p><b>File:</b> ' . self::editorLink($call['args'][0], $previous->getParsedLine()) . '</p>' . ($previous->getParsedLine() ? BlueScreen::highlightFile($call['args'][0], $previous->getParsedLine()) : '') . '<p>' . $previous->getMessage() . ' </p>');
     }
 }
Ejemplo n.º 11
0
</style>

<h1>Document HTML validation (<?php 
echo $counter;
?>
 errors)</h1>

<div class="tracy-inner Laravel-HtmlValidatorPanel">
    <table>
        <?php 
foreach ($errors as $error) {
    ?>
        <tr><td><span class="severenity-<?php 
    echo (int) $error->level;
    ?>
">
            <?php 
    echo htmlspecialchars($severenity[$error->level] . ' on column ' . $error->column . ': ' . $error->message);
    ?>
        </span></td></tr>
        <tr><td>
            <?php 
    echo \Tracy\BlueScreen::highlightPhp($html, $error->line, 10);
    ?>
        </td></tr>
        <?php 
}
?>
	</table>
</div>
Ejemplo n.º 12
0
 public static function addPanel($e)
 {
     if ($e instanceof \obo\Exceptions\Exception && $e->foreseenFileError !== null && $e->foreseenLineError !== null) {
         return ["tab" => "Foreseen Error", "panel" => \Tracy\BlueScreen::highlightFile($e->foreseenFileError, (int) $e->foreseenLineError, 20)];
     }
 }
Ejemplo n.º 13
0
 /**
  * Renders SQL query string to Nette debug bluescreen when available.
  * @param NeevoException $e
  * @return array
  */
 public function renderException($e)
 {
     if (!($e instanceof NeevoException && $e->getSql())) {
         return;
     }
     list($file, $line) = $this->failedQuerySource;
     return array('tab' => 'SQL', 'panel' => Manager::highlightSql($e->getSql()) . '<p><b>File:</b> ' . Helpers::editorLink($file, $line) . " &nbsp; <b>Line:</b> {$line}</p>" . ($line ? BlueScreen::highlightFile($file, $line) : '') . 'Neevo v' . Manager::VERSION);
 }
Ejemplo n.º 14
0
 public static function register(\Tracy\BlueScreen $blueScreen)
 {
     $blueScreen->addPanel([static::class, 'render']);
 }