Пример #1
0
 /**
  * Formats a backtrace as a string
  *
  * @param \r8\Backtrace $backtrace The backtrace being formatted
  * @return String
  */
 public function format(\r8\Backtrace $backtrace)
 {
     $position = $backtrace->count();
     $formatted = $this->formatter->prefix();
     foreach ($backtrace as $event) {
         $position--;
         if ($event instanceof \r8\Backtrace\Event\Main) {
             $formatted .= $this->formatter->main($position, $event->getFile());
         } else {
             $formatted .= $this->formatter->event($position, $event->getResolvedName(), $event->getArgs(), $event->getFile(), $event->getLine());
         }
     }
     return $formatted . $this->formatter->suffix();
 }
Пример #2
0
 /**
  * Returns the backtrace that lead up to this error
  *
  * @return \r8\Backtrace
  */
 public function getBacktrace()
 {
     if (!isset($this->backtrace)) {
         $this->backtrace = \r8\Backtrace::from($this->exception->getTrace());
         $this->backtrace->unshiftEvent(new \r8\Backtrace\Event\Func("throw", $this->exception->getFile(), $this->exception->getLine(), array($this->exception)));
     }
     return $this->backtrace;
 }
Пример #3
0
 public function testDump()
 {
     ob_start();
     \r8\Backtrace::dump();
     $result = ob_get_clean();
     $this->assertGreaterThan(0, strlen($result));
     $this->assertContains("testDump", $result);
     $this->assertNotContains('\\r8\\Backtrace', $result);
 }
Пример #4
0
 */
\r8\Autoload::getInstance()->register('r8', r8_DIR_CLASSES)->register('r8\\iface', r8_DIR_INTERFACES)->register('r8\\Test', r8_DIR_TEST);
spl_autoload_register(array(\r8\Autoload::getInstance(), "load"));
/**
 * Take a snapshot of the environment
 */
\r8\Env::Request();
/**
 * Set up error handling, but only if it isn't being suppressed by the including code
 */
if (!defined("r8_SUPPRESS_HANDLERS")) {
    // Register the error handler
    set_error_handler(function ($code, $message, $file, $line) {
        $level = (int) ini_get('error_reporting');
        $code = (int) $code;
        if (!($code & $level)) {
            return TRUE;
        }
        $backtrace = \r8\Backtrace::create()->popEvent();
        \r8\Error::getInstance()->handle(new \r8\Error\PHP($file, $line, $code, $message, $backtrace));
    });
    // Register an exception handler
    set_exception_handler(function ($exception) {
        \r8\Error::getInstance()->handle(new \r8\Error\Exception($exception));
    });
    // Hook in the error handler to the error log
    \r8\Error::getInstance()->register(new \r8\Error\Handler\Stream(new \r8\Error\Formatter\JSON(\r8\Env::request()), new \r8\Stream\Out\ErrorLog()));
    // Hook in the error handler to output the error to the client
    \r8\Error::getInstance()->register(new \r8\Error\Handler\IniDisplay(new \r8\Error\Handler\Stream(\r8\Env::request()->isCLI() ? new \r8\Error\Formatter\Text(\r8\Env::request()) : new \r8\Error\Formatter\HTML(\r8\Env::request()), new \r8\Stream\Out\StdOut())));
}
// @codeCoverageIgnoreEnd