/**
  * @param  Exception
  * @return void
  * @throws Nette\Application\AbortException
  */
 public function actionDefault($exception)
 {
     if ($exception instanceof Nette\Application\BadRequestException) {
         $code = $exception->getCode();
         // load template 403.latte or 404.latte or ... 4xx.latte
         $this->setView(in_array($code, array(403, 404, 405, 410, 500)) ? $code : '4xx');
         if (Debugger::isEnabled()) {
             // log to access.log
             Debugger::log("HTTP code {$code}: {$exception->getMessage()} in {$exception->getFile()}:{$exception->getLine()}", 'access');
         }
     } else {
         $this->setView('500');
         // load template 500.latte
         if (Debugger::isEnabled()) {
             Debugger::log($exception, Debugger::ERROR);
             // and log exception
         }
     }
     $this->template->exception = $exception;
     if ($this->isAjax()) {
         // AJAX request? Note this error in payload.
         $this->payload->error = true;
         $this->terminate();
     }
 }
Exemplo n.º 2
0
 /**
  * @param $tempDir
  * @param array $guzzleConfig
  * @return \GuzzleHttp\Client
  * @throws \Matyx\Guzzlette\GuzzletteException
  */
 public static function createGuzzleClient($tempDir, $guzzleConfig = [])
 {
     if (isset(static::$client)) {
         return static::$client;
     }
     if (Tracy\Debugger::isEnabled()) {
         $handler = NULL;
         if (isset($guzzleConfig['handler'])) {
             $handler = $guzzleConfig['handler'];
             if (!$handler instanceof GuzzleHttp\HandlerStack) {
                 throw new GuzzletteException("Handler must be instance of " . GuzzleHttp\HandlerStack::class);
             }
         } else {
             $handler = GuzzleHttp\HandlerStack::create();
         }
         $requestStack = new RequestStack();
         Tracy\Debugger::getBar()->addPanel(new TracyPanel($tempDir, $requestStack));
         $handler->push(function (callable $handler) use($requestStack) {
             return function ($request, array $options) use($handler, $requestStack) {
                 Tracy\Debugger::timer();
                 $guzzletteRequest = new Request();
                 $guzzletteRequest->request = $request;
                 return $handler($request, $options)->then(function ($response) use($requestStack, $guzzletteRequest) {
                     $guzzletteRequest->time = Tracy\Debugger::timer();
                     $guzzletteRequest->response = $response;
                     $requestStack->addRequest($guzzletteRequest);
                     return $response;
                 });
             };
         });
         $guzzleConfig['handler'] = $handler;
     }
     static::$client = new GuzzleHttp\Client($guzzleConfig);
     return static::$client;
 }
 public function handleGetExceptionLogFile()
 {
     if (Debugger::isEnabled() && Debugger::getBar()) {
         $presenter = $this->getPresenter(true);
         echo file_exists($filename = $presenter->getParameter('file')) ? file_get_contents($filename) : '"' . $this->getParameter('file') . '" not found.';
         $presenter->terminate();
     }
 }
Exemplo n.º 4
0
 /**
  * @param Application $sender
  * @param \Exception  $e
  */
 public static function sendExceptionLogFile(Nette\Application\Application $sender, \Exception $e)
 {
     /** @var $presenter Presenter */
     if (Debugger::isEnabled() && Debugger::getBar() && ($presenter = $sender->getPresenter()) && preg_match('/exceptionLogFile/', $e->getMessage())) {
         echo file_exists($filename = $presenter->getParameter('file')) ? $presenter->payload->dibiPanel = file_get_contents($filename) : '"' . $presenter->getParameter('file') . '" not found.';
         //Debugger::$bar = false;
         die;
     }
 }
Exemplo n.º 5
0
 /**
  * Must be called to enable process monitoring
  *
  * @param string $msg
  * @return void
  */
 public static function start($msg = 'process monitor starts...')
 {
     if (!Debugger::isEnabled()) {
         return;
     }
     self::$consoleMode = !(empty($_SERVER['HTTP_X_REQUESTED_WITH']) && preg_match('#^Content-Type: text/html#im', implode("\n", headers_list())));
     if (self::$consoleMode) {
         self::$lineEnding = "\n";
     }
     for ($i = 0; $i < ob_get_level(); $i++) {
         ob_end_flush();
     }
     self::$enabled = true;
     self::$startTime = microtime(true);
     self::$time = self::$startTime;
     self::addSummary($msg . ' (reportMode: ' . self::$reportModes[self::$reportMode] . ')');
 }
 public function onKernelException(GetResponseForExceptionEvent $event)
 {
     $exception = $event->getException();
     if (Debugger::isEnabled() && !$this->isIgnoredException($exception)) {
         if ($this->storeUsernameInServerVariable && $this->tokenStorage !== null) {
             $this->storeUsernameInServerVariable();
         }
         if (Debugger::$productionMode === true) {
             Debugger::log($exception, Debugger::ERROR);
         } else {
             if (Debugger::$productionMode === false) {
                 ob_start();
                 Debugger::exceptionHandler($exception, true);
                 $event->setResponse(new Response(ob_get_contents()));
                 ob_clean();
             }
         }
     }
 }
Exemplo n.º 7
0
<?php

use Gantry\Framework\Gantry;
try {
    // Get Gantry instance and return it.
    $gantry = Gantry::instance();
    // Initialize the template if not done already.
    if (!isset($gantry['theme.name'])) {
        $gantry['theme.path'] = dirname(__DIR__);
        $gantry['theme.name'] = $theme;
    }
    // Only a single template can be loaded at any time.
    if (!isset($gantry['theme'])) {
        include_once __DIR__ . '/theme.php';
    }
    return $gantry;
} catch (Exception $e) {
    // Oops, something went wrong!
    if (class_exists('\\Tracy\\Debugger') && \Tracy\Debugger::isEnabled() && !\Tracy\Debugger::$productionMode) {
        // We have Tracy enabled; will display and/or log error with it.
        throw $e;
    }
    // In frontend we want to prevent template from loading.
    die('Failed to load template: ' . $e->getMessage());
}
Exemplo n.º 8
0
 public function renderDefault()
 {
     $this->template->isManager = $this->getUser()->isInRole('beer_manager');
     $this->template->userId = $this->getUser()->getId();
     $this->template->development = Debugger::isEnabled();
 }
Exemplo n.º 9
0
 public function log($msg)
 {
     if (Debugger::isEnabled()) {
         Debugger::log($msg, self::$logPriority);
     }
 }
Exemplo n.º 10
0
 /**
  * Binds panel to debug bar.
  */
 public function bindToBar()
 {
     // No SQL capturing in CLI or when debugger is off or when in production mode
     if (php_sapi_name() === 'cli' || !Debugger::isEnabled() || Debugger::$productionMode) {
         return;
     }
     $this->entityManager->getConfiguration()->setSQLLogger($this);
     $this->connection = $this->entityManager->getConnection();
     Debugger::getBar()->addPanel($this);
 }