本文整理汇总了PHP中Nette\Diagnostics\Debugger::log方法的典型用法代码示例。如果您正苦于以下问题:PHP Debugger::log方法的具体用法?PHP Debugger::log怎么用?PHP Debugger::log使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Nette\Diagnostics\Debugger
的用法示例。
在下文中一共展示了Debugger::log方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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;
}
示例2: 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');
}
}
示例3: 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;
}
示例4: l
/**
* @param string $message
*/
function l($message)
{
$message = array_map(function ($message) {
return !is_scalar($message) ? Nette\Utils\Json::encode($message) : $message;
}, func_get_args());
Nette\Diagnostics\Debugger::log(implode(', ', $message));
}
示例5: 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();
}
}
示例6: 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);
}
}
}
示例7: 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();
}
}
示例8: authenticate
/**
* @param Method $element
* @throws \Flame\Rest\Security\ForbiddenRequestException
*/
public function authenticate(Method $element)
{
$ip = $this->getClientIp();
if (!in_array($ip, $this->allowedIps)) {
Debugger::log('Banned ip "' . $ip . '"', Debugger::DETECT);
throw new ForbiddenRequestException();
}
}
示例9: log
/**
* Wrapper for Debugger::log() method
* @param string $message
* @param int $priority
*/
public static function log($message, $priority = NDebugger::INFO)
{
NDebugger::log($message, $priority);
if (!$message instanceof \Exception) {
$message = new \Exception($message);
}
if (self::$sendErrors && $priority == NDebugger::ERROR) {
Rollbar::report_message($message);
}
}
示例10: dlog
/**
* Nette\Diagnostics\Debugger::log() shortcut.
*/
function dlog($var = NULL)
{
if (func_num_args() === 0) {
Debugger::log(new Exception(), 'dlog');
}
foreach (func_get_args() as $arg) {
Debugger::log($arg, 'dlog');
}
return $var;
}
示例11: renderDefault
public function renderDefault($exception)
{
if ($this->isAjax()) {
$this->payload->error = TRUE;
$this->terminate();
} elseif ($exception instanceof Nette\Application\BadRequestException) {
$this->setView('404');
} else {
$this->setView('500');
Debugger::log($exception, Debugger::ERROR);
}
}
示例12: run
/**
* @return Application\IResponse
*/
public function run(Application\Request $request)
{
$e = $request->parameters['exception'];
if ($e instanceof Application\BadRequestException) {
$code = $e->getCode();
} else {
$code = 500;
Debugger::log($e, Debugger::ERROR);
}
ob_start();
require __DIR__ . '/templates/error.phtml';
return new Application\Responses\TextResponse(ob_get_clean());
}
示例13: actionDefault
public function actionDefault()
{
try {
$this->db->beginTransaction();
$this->db->table('addons_resources')->delete();
foreach ($this->db->table('addons') as $addon) {
$this->updateAddon($addon);
}
$this->db->commit();
} catch (\PDOException $e) {
Debugger::log($e);
$this->db->rollBack();
}
}
示例14: __destruct
public function __destruct()
{
// Pokud mam rozpracovanou nejakou objednavku a nebyla prave ulozena do DB,
// tak si ji ulozim do session
if (isset($this->_order) && !$this->_order->orderSent()) {
// Musim zachytavat vyjimky a logovat je, protoze pri destructu uz je stranka
// vyrenderovana a nelze zobrazit chybove hlaseni
try {
$this->_order->save();
} catch (\Exception $e) {
Nette\Diagnostics\Debugger::log($e);
Nette\Diagnostics\Debugger::log('Error saving shop order into session because of ' . get_class($e) . ': ' . md5($e), Nette\Diagnostics\Debugger::CRITICAL);
}
}
}
示例15: renderDefault
/**
* @param Exception
* @return void
*/
public function renderDefault($exception)
{
if ($this->isAjax()) {
// AJAX request? Just note this error in payload.
$this->payload->error = TRUE;
$this->terminate();
}
$code = $exception->getCode();
Debugger::log("HTTP code {$code}: {$exception->getMessage()} in {$exception->getFile()}:{$exception->getLine()}", 'access');
if (in_array($code, array(403, 404, 500))) {
$page = $this->pageRepository->findOneBy(array('special' => $code));
if ($page) {
$this->forward(':Cms:Pages:Text:Route:', array('routeId' => $page->mainRoute->id, 'pageId' => $page->id));
}
}
}