本文整理汇总了PHP中Tracy\Debugger::log方法的典型用法代码示例。如果您正苦于以下问题:PHP Debugger::log方法的具体用法?PHP Debugger::log怎么用?PHP Debugger::log使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Tracy\Debugger
的用法示例。
在下文中一共展示了Debugger::log方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: sendBackgroundGetRequest
/**
* Funkce pro odeslání GET požadavku bez čekání na získání odpovědi
* @param string $url
* @throws \Exception
*/
public static function sendBackgroundGetRequest($url)
{
$url = new Url($url);
$host = $url->getHost();
if (empty($host)) {
$host = 'localhost';
}
#region parametry připojení
switch ($url->getScheme()) {
case 'https':
$scheme = 'ssl://';
$port = 443;
break;
case 'http':
default:
$scheme = '';
$port = 80;
}
$urlPort = $url->getPort();
if (!empty($urlPort)) {
$port = $urlPort;
}
#endregion
$fp = @fsockopen($scheme . $host, $port, $errno, $errstr, self::REQUEST_TIMEOUT);
if (!$fp) {
Debugger::log($errstr, ILogger::ERROR);
throw new \Exception($errstr, $errno);
}
$path = $url->getPath() . ($url->getQuery() != "" ? '?' . $url->getQuery() : '');
fputs($fp, "GET " . $path . " HTTP/1.0\r\nHost: " . $host . "\r\n\r\n");
fputs($fp, "Connection: close\r\n");
fputs($fp, "\r\n");
}
示例2: createContainer
/**
* @param array $configs
* @return Nette\DI\Container
*/
protected function createContainer(array $configs = [])
{
$sl = $this->parentCreateContainer($configs);
/** @var DbConnectionMock $db */
$db = $sl->getByType('Doctrine\\DBAL\\Connection');
if (!$db instanceof DbConnectionMock) {
$serviceNames = $sl->findByType('Doctrine\\DBAL\\Connection');
throw new \LogicException(sprintf('The service %s should be instance of Kdyby\\TesterExtras\\DbConnectionMock, to allow lazy schema initialization', reset($serviceNames)));
}
$db->onConnect[] = function (Connection $db) use($sl) {
if ($this->databaseName !== NULL) {
return;
}
try {
if (!method_exists($this, 'doSetupDatabase')) {
throw new \LogicException(sprintf("Method %s:%s is not implemented", get_class($this), __FUNCTION__));
}
$this->doSetupDatabase($db);
} catch (\Exception $e) {
Tracy\Debugger::log($e, Tracy\Debugger::ERROR);
Assert::fail($e->getMessage());
}
};
return $sl;
}
示例3: actionDefault
/**
* Provide auto merge
*/
public function actionDefault()
{
$payload = $this->httpRequest->getRawBody();
if (!$payload) {
Debugger::log('No payload data', Debugger::ERROR);
$this->terminate();
}
$data = json_decode($payload, true);
if (!$data) {
Debugger::log('json_decode error', Debugger::ERROR);
$this->terminate();
}
if ($data['object_kind'] != 'note') {
Debugger::log('Only notes object kind processing now. *' . $data['object_kind'] . '* given', Debugger::ERROR);
$this->terminate();
}
$projectId = isset($data['merge_request']['source_project_id']) ? $data['merge_request']['source_project_id'] : false;
$mergeRequestId = isset($data['merge_request']['id']) ? $data['merge_request']['id'] : false;
if (!$projectId || !$mergeRequestId) {
Debugger::log('projectId or mergeRequestId missing', Debugger::ERROR);
$this->terminate();
}
$project = $this->projectRepository->findByGitlabId($projectId);
if (!$project) {
Debugger::log('Project ' . $projectId . ' is not allowed to auto merge', Debugger::ERROR);
$this->terminate();
}
$mr = $this->gitlabClient->api('mr')->show($projectId, $mergeRequestId);
$mergeRequest = $this->mergeRequestBuilder->create($mr, $data);
if ($mergeRequest->canBeAutoMerged($project->positive_votes)) {
$this->gitlabClient->api('mr')->merge($projectId, $mergeRequestId, 'Auto merged');
}
}
示例4: handleRequest
private function handleRequest(React\Http\Request $request, React\Http\Response $response)
{
try {
$container = $this->containerFactory->createContainer();
/** @var HttpRequestFactory $requestFactory */
$requestFactory = $container->getByType(HttpRequestFactory::class);
$requestFactory->setFakeHttpRequest($this->createNetteHttpRequest($request));
/** @var CliRouter $router */
$cliRouter = $container->getService('console.router');
$cliRouter->setIsCli(FALSE);
/** @var Nette\Application\Application $application */
$application = $container->getByType(Nette\Application\Application::class);
array_unshift($application->onError, function () {
throw new AbortException();
});
ob_start();
$application->run();
$responseBody = ob_get_contents();
ob_end_clean();
$response->writeHead(200, array('Content-Type' => 'text/html; charset=utf-8'));
$response->end($responseBody);
} catch (\Exception $e) {
Debugger::log($e, Debugger::EXCEPTION);
$response->writeHead(500, array('Content-Type' => 'text/plain'));
$response->end('Internal Server Error');
}
}
示例5: setupWorkedHours
/**
* @param WorkedHours $workedHours
* @return WorkedHours
* @throws \DibiException
*/
public function setupWorkedHours(WorkedHours $workedHours)
{
$values = ['workStart' => $workedHours->workStart->getTime(), 'workEnd' => $workedHours->workEnd->getTime(), 'lunch' => $workedHours->lunch->getTime(), 'otherHours' => $workedHours->otherHours->getTime()];
try {
$this->connection->query('LOCK TABLES worked_hours WRITE');
$data = $this->connection->query('SELECT workedHoursID AS id FROM worked_hours
WHERE %and', $values)->fetch();
if ($data === false) {
$this->connection->query('INSERT INTO [worked_hours]', $values);
$id = $this->connection->getInsertId();
} else {
$id = $data['id'];
}
$this->connection->query('UNLOCK TABLES');
if (!$workedHours->isDetached()) {
$workedHours->detach();
}
$workedHours->makeAlive($this->entityFactory, $this->connection, $this->mapper);
$workedHours->attach($id);
return $workedHours;
} catch (\DibiException $e) {
$this->connection->query('UNLOCK TABLES');
Debugger::log($e, Debugger::ERROR);
throw $e;
}
}
示例6: renderDefault
/**
* Nette render default method
*
* @return void
*/
public function renderDefault()
{
$start = microtime(true);
$this->sendCorsHeaders();
$hand = $this->getHandler();
$handler = $hand['handler'];
$authorization = $hand['authorization'];
if ($this->checkAuth($authorization) === false) {
return;
}
$params = $this->processParams($handler);
if ($params === false) {
return;
}
try {
$response = $handler->handle($params);
$code = $response->getCode();
} catch (Exception $exception) {
$response = new JsonApiResponse(500, ['status' => 'error', 'message' => 'Internal server error']);
$code = $response->getCode();
Debugger::log($exception, Debugger::EXCEPTION);
}
$end = microtime(true);
if ($this->context->findByType('Tomaj\\NetteApi\\Logger\\ApiLoggerInterface')) {
$this->logRequest($this->context->getByType('Tomaj\\NetteApi\\Logger\\ApiLoggerInterface'), $code, $end - $start);
}
// output to nette
$this->getHttpResponse()->setCode($code);
$this->sendResponse($response);
}
示例7: actionDefault
/**
* @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();
}
}
示例8: 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 ' . Dumper::toText($expected_sig) . ', but given ' . Dumper::toText($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 ' . Dumper::toText($expected_sig) . ', but given ' . Dumper::toText($sig), 'facebook');
return NULL;
}
return $data;
}
示例9: renderDefault
public function renderDefault()
{
$this->template->anyVariable = 'any value';
// $dao = $this->articles;
$this->template->articles = $this->articles->getArticles()->findAll();
$posts = $this->EntityManager->getRepository(Posts::getClassName());
$this->template->posts = $posts->findAll();
$this->template->myparametr = $this->context->parameters['first_parametr'];
// $this->template->test = $this->doSomeRefactoring('Hello world from blog');
// $post = new Posts();
// $post->title = 'New title';
// $post->text = 'New text New textNew text';
// $post->created_at = new \Nette\Utils\DateTime;
//
//
// $this->EntityManager->persist($post);
// $this->EntityManager->flush();
// $dao = $this->EntityManager->getRepository(Posts::getClassName());
// $dao->setTitle('test');
// $dao->__call('set', ['title' => 'my title']);
// dump($dao->__isset('title'));
// $dao->__set('title', 'test');
try {
$this->checkNum(2);
\Tracy\Debugger::barDump('If you see this, the number is 1 or below');
} catch (Nette\Application\BadRequestException $e) {
Debugger::log('Message: ' . $e->getMessage());
var_dump($e->getMessage());
}
// finally {
// \Tracy\Debugger::barDump('Got here Finally');
// }
}
示例10: formSucceeded
/**
* Callback for ForgottenPasswordForm onSuccess event.
* @param Form $form
* @param ArrayHash $values
*/
public function formSucceeded(Form $form, $values)
{
$user = $this->userManager->findByEmail($values->email);
if (!$user) {
$form->addError('No user with given email found');
return;
}
$password = Nette\Utils\Random::generate(10);
$this->userManager->setNewPassword($user->id, $password);
try {
// !!! Never send passwords through email !!!
// This is only for demonstration purposes of Notejam.
// Ideally, you can create a unique link where user can change his password
// himself for limited amount of time, and then send the link.
$mail = new Nette\Mail\Message();
$mail->setFrom('noreply@notejamapp.com', 'Notejamapp');
$mail->addTo($user->email);
$mail->setSubject('New notejam password');
$mail->setBody(sprintf('Your new password: %s', $password));
$this->mailer->send($mail);
} catch (Nette\Mail\SendException $e) {
Debugger::log($e, Debugger::EXCEPTION);
$form->addError('Could not send email with new password');
}
}
示例11: process
/**
* Default form handler
*/
public function process()
{
/** @var ArrayHash $values */
$values = $this->values;
try {
$this->onBeforeProcess($this, $values);
if (isset($values->id)) {
$this->onBeforeUpdate($this, $values);
$arr = (array) $values;
unset($arr['id']);
$row = $this->selection->wherePrimary($values->id)->fetch();
$row->update($arr);
$this->onAfterUpdate($row, $this, $values);
} else {
$this->onBeforeInsert($this, $values);
$row = $this->selection->insert($values);
$this->onAfterInsert($row, $this, $values);
}
$this->onAfterProcess($row, $this, $values);
} catch (\PDOException $e) {
$this->addError($e->getMessage());
dump($e);
Debugger::log($e);
}
}
示例12: setSystemSettings
private function setSystemSettings()
{
try {
$this->systemSettings = $this->systemSettingsFacade->findAll();
} catch (EntitiesNotFoundException $ex) {
\Tracy\Debugger::log($ex);
$this->systemSettings = null;
}
}
示例13: catchException
/**
* Odchytí výjimku, v případě, že je program v produkčním modu, je výjimka zalogována a komponentě předána Flash
* Message. Pokud ne, je vyhozena dál.
* @param \Exception $exception
* @param string $message
* @throws \Exception
*/
protected function catchException(\Exception $exception, $message = "global.errors.action-error")
{
if (\Tracy\Debugger::$productionMode) {
\Tracy\Debugger::log($exception->getMessage(), \Tracy\Logger::EXCEPTION);
$this->flashMessage($this->t($message), "danger");
} else {
throw $exception;
}
}
示例14: renderDefault
public function renderDefault()
{
try {
$this->template->articles = $this->articleFacade->findAllVisible($this->paginator->getPageLimit());
} catch (EntityNotFoundException $ex) {
\Tracy\Debugger::log($ex);
$this->template->articles = false;
}
}
示例15: catchFormError
/**
* Odchytí výjimku v rámci zpracování formuláře, v případě, že je program v produkčním modu, je výjimka zalogována
* a formuláře přidána chyba. Pokud ne, je vyhozena dál.
* @param \Exception $exception
* @param Nette\Application\UI\Form $form
* @param string $message
* @throws \Exception
*/
protected function catchFormError(\Exception $exception, \Nette\Application\UI\Form $form, $message = "global.errors.action-error")
{
if (\Tracy\Debugger::$productionMode) {
\Tracy\Debugger::log($exception->getMessage(), \Tracy\Logger::EXCEPTION);
$form->addError($this->t($message));
} else {
throw $exception;
}
}