当前位置: 首页>>代码示例>>PHP>>正文


PHP Diagnostics\Debugger类代码示例

本文整理汇总了PHP中Nette\Diagnostics\Debugger的典型用法代码示例。如果您正苦于以下问题:PHP Debugger类的具体用法?PHP Debugger怎么用?PHP Debugger使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了Debugger类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: dbConnect

	/**
	 * Connection factory. Connects to DB.
	 *
	 * @param Nette\DI\IContainer $container
	 * @return NotORM
	 */
	public static function dbConnect(IContainer $container)
	{
		$db = $container->params['database'];
		$dsn = (isset($db->port))
			? "{$db->driver}:host={$db->host};dbname={$db->database};port={$db->port}"
			: "{$db->driver}:host={$db->host};dbname={$db->database}";

		$pdo = new PDO($dsn, $db->username, $db->password);
		$pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
		$pdo->query('SET NAMES utf8');

		$conn = new NotORM($pdo, new NotORM_Structure_Convention('id', '%s_id', '%ss'), new NotORM_Cache_Session);

		if ($db->profiler) {
			$panel = Panel::getInstance();
			$panel->setPlatform($db->driver);
			Debugger::addPanel($panel);

			$conn->debug = function($query, $parameters) {
				Panel::getInstance()->logQuery($query, $parameters);
			};
		}

		return $conn;
	}
开发者ID:JanVoracek,项目名称:Diggriola,代码行数:31,代码来源:ModelLoader.php

示例2: __construct

 /**
  * @param ItemRepository $productRepository
  */
 public function __construct(ItemRepository $productRepository)
 {
     parent::__construct();
     $this->productRepository = $productRepository;
     $this->absoluteUrls = true;
     Debugger::$bar = false;
 }
开发者ID:venne,项目名称:catalog-module,代码行数:10,代码来源:FeedPresenter.php

示例3: renderDefault

 /**
  * @param  Exception
  * @return void
  */
 public function renderDefault($exception)
 {
     // this block is there due to nette caching issue 11
     // https://github.com/nette/caching/issues/11
     if ($exception instanceof Nette\InvalidStateException) {
         $temp = $this->context->parameters['tempDir'];
         //unlink($temp . '/btfj.dat');
         rename($temp . '/btfj.dat', $temp . '/btfj.dat' . microtime(TRUE));
     }
     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');
         // 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
         Debugger::log($exception, Debugger::ERROR);
         // and log exception
     }
     if ($this->isAjax()) {
         // AJAX request? Note this error in payload.
         $this->payload->error = TRUE;
         $this->terminate();
     }
 }
开发者ID:fuca,项目名称:sportsclub,代码行数:31,代码来源:ErrorPresenter.php

示例4: stopQuery

	public function stopQuery()
	{
		$keys = array_keys($this->queries);
		$key = end($keys);
		$this->queries[$key][2] = Debugger::timer('doctrine');
		$this->totalTime += $this->queries[$key][2];
	}
开发者ID:norbe,项目名称:framework,代码行数:7,代码来源:Panel.php

示例5: decode

 /**
  * Parses a signed_request and validates the signature.
  *
  * @param string $signedRequest A signed token
  * @param string $appSecret
  *
  * @return array The payload inside it or null if the sig is wrong
  */
 public static function decode($signedRequest, $appSecret)
 {
     if (!$signedRequest || strpos($signedRequest, '.') === false) {
         Debugger::log('Signed request is invalid! ' . json_encode($signedRequest), 'facebook');
         return NULL;
     }
     list($encoded_sig, $payload) = explode('.', $signedRequest, 2);
     // decode the data
     $sig = Helpers::base64UrlDecode($encoded_sig);
     $data = Json::decode(Helpers::base64UrlDecode($payload), Json::FORCE_ARRAY);
     if (!isset($data['algorithm']) || strtoupper($data['algorithm']) !== Configuration::SIGNED_REQUEST_ALGORITHM) {
         Debugger::log("Unknown algorithm '{$data['algorithm']}', expected " . Configuration::SIGNED_REQUEST_ALGORITHM, 'facebook');
         return NULL;
     }
     // check sig
     $expected_sig = hash_hmac('sha256', $payload, $appSecret, $raw = TRUE);
     if (strlen($expected_sig) !== strlen($sig)) {
         Debugger::log('Bad Signed JSON signature! Expected ' . self::dump($expected_sig) . ', but given ' . self::dump($sig), 'facebook');
         return NULL;
     }
     $result = 0;
     for ($i = 0; $i < strlen($expected_sig); $i++) {
         $result |= ord($expected_sig[$i]) ^ ord($sig[$i]);
     }
     if ($result !== 0) {
         Debugger::log('Bad Signed JSON signature! Expected ' . self::dump($expected_sig) . ', but given ' . self::dump($sig), 'facebook');
         return NULL;
     }
     return $data;
 }
开发者ID:vboss,项目名称:facebook,代码行数:38,代码来源:SignedRequest.php

示例6: stopQuery

 public function stopQuery()
 {
     if ($this->explainRunning) {
         return;
     }
     $keys = array_keys($this->queries);
     $key = end($keys);
     $this->queries[$key][self::TIME] = Debugger::timer('doctrine');
     $this->totalTime += $this->queries[$key][self::TIME];
     // get EXPLAIN for SELECT queries
     if ($this->doExplains) {
         if ($this->connection === NULL) {
             throw new \Nette\InvalidStateException('You must set a Doctrine\\DBAL\\Connection to get EXPLAIN.');
         }
         $query = $this->queries[$key][self::SQL];
         if (strtoupper(substr(ltrim($query), 0, 6)) !== 'SELECT') {
             // only SELECTs are supported
             return;
         }
         // prevent logging explains & infinite recursion
         $this->explainRunning = TRUE;
         $params = $this->queries[$key][self::PARAMS];
         $types = $this->queries[$key][self::TYPES];
         $stmt = $this->connection->executeQuery('EXPLAIN ' . $query, $params, $types);
         $this->queries[$key][self::EXPLAIN] = $stmt->fetchAll();
         $this->explainRunning = FALSE;
     }
 }
开发者ID:janmarek,项目名称:doctrine,代码行数:28,代码来源:ConnectionPanel.php

示例7: logQuery

 public function logQuery(Nette\Database\Connection $connection, $result)
 {
     if ($this->disabled) {
         return;
     }
     $this->count++;
     $source = NULL;
     $trace = $result instanceof \PDOException ? $result->getTrace() : debug_backtrace(PHP_VERSION_ID >= 50306 ? DEBUG_BACKTRACE_IGNORE_ARGS : FALSE);
     foreach ($trace as $row) {
         if (isset($row['file']) && is_file($row['file']) && !Nette\Diagnostics\Debugger::getBluescreen()->isCollapsed($row['file'])) {
             if (isset($row['function']) && strpos($row['function'], 'call_user_func') === 0 || isset($row['class']) && is_subclass_of($row['class'], '\\Nette\\Database\\Connection')) {
                 continue;
             }
             $source = array($row['file'], (int) $row['line']);
             break;
         }
     }
     if ($result instanceof Nette\Database\ResultSet) {
         $this->totalTime += $result->getTime();
         if ($this->count < $this->maxQueries) {
             $this->queries[] = array($connection, $result->getQueryString(), $result->getParameters(), $source, $result->getTime(), $result->getRowCount(), NULL);
         }
     } elseif ($result instanceof \PDOException && $this->count < $this->maxQueries) {
         $this->queries[] = array($connection, $result->queryString, NULL, $source, NULL, NULL, $result->getMessage());
     }
 }
开发者ID:cujan,项目名称:atlashornin,代码行数:26,代码来源:ConnectionPanel.php

示例8: createComponentAddSetting

 protected function createComponentAddSetting()
 {
     $form = new Form();
     $form->addText('key', 'Klíč')->setRequired('Zadejte klíč nastavení');
     $form->addText('value', 'Hodnota')->setRequired('Zadejte hodnotu nastavení');
     $form->addSubmit('send', 'Zapsat');
     $form->onSuccess[] = function (Form $f) {
         try {
             $val = $f->values;
             $this->settings->set($val->key, $val->value);
             $this->settings->push();
             //Write
             $this->logger->log('System', 'edit', "%user% změnila(a) nastavení");
             $msg = $this->flashMessage("Nastavení bylo zapsáno", 'success');
             $msg->title = 'Yehet!';
             $msg->icon = 'check';
             $this->redirect('this');
         } catch (\PDOException $e) {
             \Nette\Diagnostics\Debugger::log($e);
             $msg = $this->flashMessage("Něco se podělalo. Zkuste to prosím později.", 'danger');
             $msg->title = 'Oh shit!';
             $msg->icon = 'warning';
         }
     };
     return $form;
 }
开发者ID:sg3tester,项目名称:songator,代码行数:26,代码来源:SystemPresenter.php

示例9: log_write

function log_write($data, FileDownload $file, IDownloader $downloader)
{
    $cache = Environment::getCache("FileDownloader/log");
    $log = array();
    $tid = (string) $file->getTransferId();
    if (!isset($cache["registry"])) {
        $cache["registry"] = array();
    }
    $reg = $cache["registry"];
    $reg[$tid] = true;
    $cache["registry"] = $reg;
    if (isset($cache[$tid])) {
        $log = $cache[$tid];
    }
    Debugger::fireLog("Data: " . $data . "; " . $downloader->end);
    $data = $data . ": " . Helpers::bytes($file->transferredBytes) . " <->; ";
    if ($downloader instanceof AdvancedDownloader and $downloader->isInitialized()) {
        $data .= "position: " . Helpers::bytes($downloader->position) . "; ";
        //$data .= "length: ".Helpers::bytes($downloader->length)."; ";
        $data .= "http-range: " . Helpers::bytes($downloader->start) . "-" . Helpers::bytes($downloader->end) . "; ";
        $data .= "progress (con: " . round($file->transferredBytes / $downloader->end * 100) . "% X ";
        $data .= "file: " . round($downloader->position / $file->sourceFileSize * 100) . "%)";
    }
    $log[] = $data;
    $cache[$tid] = $log;
}
开发者ID:jkuchar,项目名称:FileDownloader-example,代码行数:26,代码来源:example_library.php

示例10: actionView

 /**
  * @param $id
  * @param $status
  * @throws \Nette\Application\BadRequestException
  */
 public function actionView($id, $status = null)
 {
     $interpret = $this->interpreti->find($id);
     if ($status) {
         $this->template->status = $status;
     }
     if (!$interpret) {
         throw new Nette\Application\BadRequestException("Interpret does not exists!", 404);
     }
     if ($interpret->interpret_id) {
         $msg = $this->flashMessage("Přesměrováno z '{$interpret->nazev}'");
         $msg->title = "Alias";
         $this->redirect("this", array("id" => $interpret->interpret_id));
         //If is alias => redirect to real
     }
     $this->template->interpret = $interpret;
     //Register helper fot fetching song form last.fm
     $this->template->registerhelper('songImage', function ($song, $img = 0) {
         try {
             return $this->lastfm->call('Track.getInfo', ['track' => $song->name, 'artist' => $song->interpret_name])->track->album->image[$img]->{'#text'};
         } catch (Model\Lastfm\LastfmException $e) {
             return null;
         }
     });
     //Last.fm Interpret info (images)
     try {
         $this->template->lastfm = $this->lastfm->call('Artist.getInfo', ['artist' => $interpret->nazev])->artist;
     } catch (Model\Lastfm\LastfmException $e) {
         if ($this->settings->get('lastfm_enabled', false)) {
             Debugger::log($e);
         }
     }
 }
开发者ID:sg3tester,项目名称:songator,代码行数:38,代码来源:InterpretPresenter.php

示例11: dump

 /**
  * Nette\Diagnostics\Debugger::dump() shortcut.
  * @tracySkipLocation
  */
 function dump($var)
 {
     foreach (func_get_args() as $arg) {
         Debugger::dump($arg);
     }
     return $var;
 }
开发者ID:Johnik010,项目名称:rezervace,代码行数:11,代码来源:shortcuts.php

示例12: renderDefault

 /**
  * @param  Exception
  * @return void
  */
 public function renderDefault($exception)
 {
     if ($exception) {
         $data = array('error_msg' => $exception->getMessage(), 'upd_process_id' => 'ErrorPresenter::renderDefault()');
         if (isset($this->lastLogItem) && is_object($this->lastLogItem)) {
             $this->logger->updateLogVisit($this->lastLogItem->id, $data);
         }
     }
     if ($this->isAjax()) {
         // AJAX request? Just note this error in payload.
         $this->payload->error = TRUE;
         $this->terminate();
     } elseif ($exception instanceof NA\BadRequestException || $exception instanceof HQ\UnauthorizedAccessException) {
         $code = $exception->getCode();
         if ($exception instanceof HQ\UnauthorizedAccessException) {
             // Unathorized access in admin
             $this->setView("admin403");
         } else {
             // load template 403.latte or 404.latte or ... 4xx.latte
             $this->setView(in_array($code, array(403, 404, 405, 410, 500)) ? $code : '4xx');
         }
         // 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
         $this->logger->logError($exception, 'exception', 'ErrorPresenter::LOG_EXCEPTION');
     }
 }
开发者ID:RiKap,项目名称:ErrorMonitoring,代码行数:33,代码来源:ErrorPresenter.php

示例13: generateExceptionFile

 /**
  * generateExceptionFile
  * @param Exception $exception
  * @return string
  */
 private function generateExceptionFile($exception)
 {
     $hash = md5($exception);
     $exceptionFilename = "exception-" . @date('Y-m-d-H-i-s') . "-{$hash}.html";
     foreach (new \DirectoryIterator($this->loggerDirectory) as $entry) {
         if (strpos($entry, $hash)) {
             $exceptionFilename = $entry;
             $saved = TRUE;
             break;
         }
     }
     $exceptionFilename = $this->loggerDirectory . '/' . $exceptionFilename;
     if (empty($saved) && ($logHandle = @fopen($exceptionFilename, 'w'))) {
         ob_start();
         // double buffer prevents sending HTTP headers in some PHP
         ob_start(function ($buffer) use($logHandle) {
             fwrite($logHandle, $buffer);
         }, 4096);
         Debugger::getBlueScreen()->render($exception);
         ob_end_flush();
         ob_end_clean();
         fclose($logHandle);
     }
     return $exceptionFilename;
 }
开发者ID:nasext,项目名称:logger,代码行数:30,代码来源:Logger.php

示例14: authenticate

 /**
  * @param Method $element
  * @throws \Flame\Rest\Security\ForbiddenRequestException
  */
 public function authenticate(Method $element)
 {
     $referer = $this->getReferer();
     if (!in_array($referer, $this->allowedReferers)) {
         Debugger::log('Invalid HTTP REFERER header "' . $referer . '"', Debugger::DETECT);
         throw new ForbiddenRequestException();
     }
 }
开发者ID:Budry,项目名称:TinyREST,代码行数:12,代码来源:RefererAuthenticator.php

示例15: __toString

 public function __toString()
 {
     try {
         return (string) $this->getPrimary();
     } catch (\Exception $e) {
         Nette\Diagnostics\Debugger::toStringException($e);
     }
 }
开发者ID:TheTypoMaster,项目名称:SPHERE-Framework,代码行数:8,代码来源:ActiveRow.php


注:本文中的Nette\Diagnostics\Debugger类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。