예제 #1
0
 public function register(ORM &$db)
 {
     Debugger::getBar()->addPanel($this);
     $db->debug = function ($query, $parameters, $microtime = null) {
         self::getInstance()->logQuery($query, $parameters, $microtime);
     };
 }
예제 #2
0
파일: Panel.php 프로젝트: foowie/cron
 public static function register(Cron $cron, Request $request)
 {
     $bar = Debugger::getBar();
     $panel = new static($cron, $request);
     $bar->addPanel($panel);
     return $panel;
 }
예제 #3
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]));
             }
         }
     });
 }
예제 #4
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;
 }
예제 #5
0
 public static function getBarResponse()
 {
     ob_start();
     TracyDebugger::getBar()->render();
     $content = ob_get_clean();
     return $content;
 }
예제 #6
0
 /**
  * Register the bar and register the event which will block the screen log
  */
 public static function register()
 {
     $class = new self();
     Events::addListener(array($class, 'screenLogEventListener'), 'screenLogEvent', EventPriority::NORMAL);
     $bar = Debugger::getBar();
     $bar->addPanel($class);
 }
예제 #7
0
 /**
  * Register this panel
  *
  * @param \Pagewiser\Idn\Nette\Api $idnApi IDN Api
  * @param int $layout Layout type
  * @param int $height Popup height
  *
  * @return NULL
  */
 public function register(\Pagewiser\Idn\Nette\Api $idnApi, $layout = NULL, $height = NULL)
 {
     $this->idnApi = $idnApi;
     Tracy\Debugger::getBar()->addPanel($this);
     $idnApi->onCurlCall[] = array($this, 'onCurlCall');
     $idnApi->onCurlFinished[] = array($this, 'onCurlFinished');
     $idnApi->onCurlFailed[] = array($this, 'onCurlFailed');
 }
예제 #8
0
 /**
  * @param Toggler $toggler
  */
 public function register(Toggler $toggler)
 {
     $this->toggler = $toggler;
     $this->toggler->onFeatureEvaluated[] = function ($feature, $context, $conditions, $result) {
         $this->evaluatedFeatures[] = ['feature' => $feature, 'context' => $context, 'conditions' => $conditions, 'result' => $result];
     };
     Debugger::getBar()->addPanel($this);
 }
 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();
     }
 }
예제 #10
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;
     }
 }
예제 #11
0
 /**
  * __construct.
  *
  * @method __construct
  *
  * @param array                                        $config
  * @param \Illuminate\Http\Request                     $request
  * @param \Illuminate\Contracts\Foundation\Application $app
  */
 public function __construct($config, Request $request = null, Application $app = null)
 {
     $this->request = is_null($request) === true ? Request::capture() : $request;
     $this->ajax = $this->request->ajax();
     $this->app = $app;
     $this->accepts = Arr::get($config, 'accepts', []);
     $this->showBar = Arr::get($config, 'showBar', false);
     $this->bar = Debugger::getBar();
     $this->initializeTracyDebuger($config);
     $this->loadPanels($config);
 }
 public static function simpleInit(\NotORM $notorm, PDO $pdo = null)
 {
     $self = self::getInstance();
     $self->setNotOrm($notorm);
     if ($pdo) {
         $self->setPdo($pdo);
     }
     $notorm->debug = function ($query, $parameters) use($self) {
         $self->logQuery($query, $parameters);
         $self->startQueryTimer($self->getIndex());
     };
     $notorm->debugTimer = function () use($self) {
         $self->stopQueryTimer($self->getIndex());
     };
     $self->setPlatform($pdo->getAttribute(PDO::ATTR_DRIVER_NAME));
     Debugger::getBar()->addPanel($self);
 }
예제 #13
0
파일: View.php 프로젝트: allyse/allyse
 /**
  * Fetch template
  *
  * @param string           $file
  * @param array            $data  (optional)
  * @param int|string|array $cache (optional)
  * @return string
  */
 public function fetch($file, $data = [], $cache = NULL)
 {
     // Remap cache
     if (is_int($data) === TRUE) {
         $cache = $data;
         $data = [];
     }
     // Cache params (used only for select)
     list($cacheId, $cacheLifetime) = array_values($this->cacheDefaults());
     if (is_array($cache)) {
         list($cacheId, $cacheLifetime) = array_merge(['id' => $cacheId, 'lifetime' => $cacheLifetime], $cache);
     } elseif (is_int($cache) || $cache instanceof \DateTime) {
         $cacheLifetime = $cache;
     } elseif (is_string($cache)) {
         $cacheId = $cache;
     }
     $cache = (bool) $cacheLifetime === TRUE ? TRUE : NULL;
     // Get item from cache
     if ($cache !== NULL) {
         $cacheDb = $this->call->cache();
         $cacheObj = $cacheDb->pool('/view/' . $cacheId);
         $template = $cacheDb->get($cacheObj);
     }
     // Check if cache is enabled and item is cached
     if ($cache === NULL || $cacheDb->isCached($cacheObj) === FALSE) {
         // Lock item in cache during processing data
         if ($cache !== NULL) {
             $cacheDb->lock($cacheObj);
         }
         // Assign smarty templates
         if (count($data) !== 0) {
             $this->smarty->assign($data);
         }
         $template = $this->smarty->fetch($file);
         // Save to cache
         if ($cache !== NULL) {
             $cacheDb->set($cacheObj, $template, $cacheLifetime);
         }
     }
     // Tracy panel
     if (TRACY === TRUE && Debugger::$productionMode === FALSE) {
         Debugger::getBar()->addPanel($panel = new SmartyBarPanel($this->smarty));
     }
     return $template;
 }
예제 #14
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])];
         }
     });
 }
예제 #15
0
파일: TracyBridge.php 프로젝트: hrach/nette
 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]));
             }
         }
     });
 }
예제 #16
0
 protected function registerDebugger()
 {
     $config = $this->app['config']['tracy'];
     Debugger::$time = array_get($_SERVER, 'REQUEST_TIME_FLOAT', microtime(true));
     Debugger::$maxDepth = array_get($config, 'maxDepth');
     Debugger::$maxLen = array_get($config, 'maxLen');
     Debugger::$showLocation = array_get($config, 'showLocation');
     Debugger::$strictMode = array_get($config, 'strictMode');
     Debugger::$editor = array_get($config, 'editor');
     $bar = Debugger::getBar();
     foreach ($config['panels'] as $key => $enabled) {
         if ($enabled === true or $enabled === '1') {
             $class = '\\' . __NAMESPACE__ . '\\Panels\\' . ucfirst($key) . 'Panel';
             $bar->addPanel(new $class($config, $this->app), $class);
         } elseif (is_string($enabled) === true) {
             $class = $enabled;
             $bar->addPanel(new $class($config, $this->app), $class);
         }
     }
 }
예제 #17
0
파일: Panel.php 프로젝트: librette/solarium
 public static function register(Client $solarium)
 {
     $panel = new self($solarium);
     Debugger::getBar()->addPanel($panel);
     return $panel;
 }
예제 #18
0
파일: Panel.php 프로젝트: kdyby/facebook
 /**
  * @param \Kdyby\Facebook\Api\CurlClient $client
  */
 public function register(CurlClient $client)
 {
     $client->onRequest[] = $this->begin;
     $client->onError[] = $this->failure;
     $client->onSuccess[] = $this->success;
     Debugger::getBar()->addPanel($this);
 }
예제 #19
0
파일: Panel.php 프로젝트: kdyby/google
 /**
  * @return \Tracy\Bar
  */
 private static function getDebuggerBar()
 {
     return method_exists('Tracy\\Debugger', 'getBar') ? Debugger::getBar() : Debugger::$bar;
 }
예제 #20
0
 public function register(Translator $translator)
 {
     $this->translator = $translator;
     $translator->injectPanel($this);
     Debugger::getBar()->addPanel($this, 'kdyby.translation');
     return $this;
 }
예제 #21
0
 /**
  * @param \Doctrine\DBAL\Connection $connection
  * @return Panel
  */
 public function bindConnection(Doctrine\DBAL\Connection $connection)
 {
     if ($this->connection !== NULL) {
         throw new Kdyby\Doctrine\InvalidStateException("Doctrine Panel is already bound to connection.");
     }
     $this->connection = $connection;
     // Tracy
     $this->registerBarPanel(Debugger::getBar());
     Debugger::getBlueScreen()->addPanel([$this, 'renderQueryException']);
     return $this;
 }
예제 #22
0
 public function register($connection)
 {
     Tracy\Debugger::getBar()->addPanel($this);
     //Tracy\Debugger::getBlueScreen()->addPanel(array(__CLASS__, 'renderException'));
     $connection->onEvent[] = array($this, 'logEvent');
 }
예제 #23
0
 /**
  * @param Kdyby\ElasticSearch\Client $client
  */
 public function register(Kdyby\ElasticSearch\Client $client)
 {
     $this->client = $client;
     $client->onSuccess[] = $this->success;
     $client->onError[] = $this->failure;
     Debugger::getBar()->addPanel($this);
 }
예제 #24
0
 /**
  * @param string
  */
 public function __construct($appDir = NULL)
 {
     $this->root = $appDir ? str_replace('\\', DIRECTORY_SEPARATOR, realpath(dirname($appDir))) : '';
     Debugger::getBar()->addPanel($this);
 }
예제 #25
0
 public function register(Dibi\Connection $connection)
 {
     Tracy\Debugger::getBar()->addPanel($this);
     Tracy\Debugger::getBlueScreen()->addPanel([__CLASS__, 'renderException']);
     $connection->onEvent[] = [$this, 'logEvent'];
 }
예제 #26
0
파일: Panel.php 프로젝트: kdyby/redis
 /**
  * @return \Tracy\Bar
  */
 private static function getDebuggerBar()
 {
     return Debugger::getBar();
 }
예제 #27
0
 public function getBar()
 {
     return Debugger::getBar();
 }
예제 #28
0
 public static function createDebugPanel($connection, $explain = TRUE, $name = NULL)
 {
     $panel = new Nette\Bridges\DatabaseTracy\ConnectionPanel($connection);
     $panel->explain = $explain;
     $panel->name = $name;
     Tracy\Debugger::getBar()->addPanel($panel);
     return $panel;
 }
예제 #29
0
 /**
  * dispatch.
  *
  * @method dispatch
  *
  * @return string
  */
 public function dispatch()
 {
     if (session_status() !== PHP_SESSION_ACTIVE) {
         ini_set('session.use_cookies', '1');
         ini_set('session.use_only_cookies', '1');
         ini_set('session.use_trans_sid', '0');
         ini_set('session.cookie_path', '/');
         ini_set('session.cookie_httponly', '1');
         @session_start();
     }
     ob_start();
     Debugger::getBar()->dispatchContent();
     return ob_get_clean();
 }
예제 #30
0
 /**
  * Inicializuje DEBUG bar.
  */
 private function initDebugBar()
 {
     if (!$this->isDebugBar) {
         $this->isDebugBar = TRUE;
         \Tracy\Debugger::getBar()->addPanel(new DynamicLoaderBar($this->count));
     }
 }