當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Debugger::formatTrace方法代碼示例

本文整理匯總了PHP中Cake\Error\Debugger::formatTrace方法的典型用法代碼示例。如果您正苦於以下問題:PHP Debugger::formatTrace方法的具體用法?PHP Debugger::formatTrace怎麽用?PHP Debugger::formatTrace使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Cake\Error\Debugger的用法示例。


在下文中一共展示了Debugger::formatTrace方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: _outputMessage

 protected function _outputMessage($template)
 {
     $error = $this->controller->viewVars['error'];
     $data = [];
     $data['class'] = 'Error';
     $data['code'] = $error->getCode();
     $data['url'] = '/' . $this->controller->request->url;
     $data['message'] = $error->getMessage();
     $data['errors'] = $this->controller->viewVars['errors'];
     if (Configure::read('debug')) {
         $data['DEBUG']['trace'] = Debugger::formatTrace($error->getTrace(), ['format' => 'array', 'args' => false]);
         $queryLog = $this->_getQueryLog();
         if ($queryLog) {
             $data['DEBUG']['queryLog'] = $queryLog;
         }
     }
     $jsonOptions = JSON_HEX_TAG | JSON_HEX_APOS | JSON_HEX_AMP | JSON_HEX_QUOT;
     if (Configure::read('debug')) {
         $jsonOptions = $jsonOptions | JSON_PRETTY_PRINT;
     }
     $this->controller->response->type('json');
     $this->controller->response->body(json_encode($data, $jsonOptions));
     $this->controller->response->statusCode($data['code']);
     return $this->controller->response;
 }
開發者ID:pwerken,項目名稱:va-void,代碼行數:25,代碼來源:ApiExceptionRenderer.php

示例2: _getErrorData

 /**
  * Helper method used to generate extra debugging data into the error template
  *
  * @return array debugging data
  */
 protected function _getErrorData()
 {
     $data = [];
     $viewVars = $this->controller->viewVars;
     if (!empty($viewVars['_serialize'])) {
         foreach ($viewVars['_serialize'] as $v) {
             $data[$v] = $viewVars[$v];
         }
     }
     if (!empty($viewVars['error']) && Configure::read('debug')) {
         $data['exception'] = ['class' => get_class($viewVars['error']), 'code' => $viewVars['error']->getCode(), 'message' => $viewVars['error']->getMessage()];
         if (!isset($data['trace'])) {
             $data['trace'] = Debugger::formatTrace($viewVars['error']->getTrace(), ['format' => 'array', 'args' => false]);
         }
     }
     return $data;
 }
開發者ID:friendsofcake,項目名稱:crud,代碼行數:22,代碼來源:ExceptionRenderer.php

示例3: render

 /**
  * Renders the response for the exception.
  *
  * @return \Cake\Network\Response The response to be sent.
  */
 public function render()
 {
     $exception = $this->error;
     $code = $this->_code($exception);
     $method = $this->_method($exception);
     $template = $this->_template($exception, $method, $code);
     $unwrapped = $this->_unwrap($exception);
     $isDebug = Configure::read('debug');
     if (($isDebug || $exception instanceof HttpException) && method_exists($this, $method)) {
         return $this->_customMethod($method, $unwrapped);
     }
     $message = $this->_message($exception, $code);
     $url = $this->controller->request->here();
     if (method_exists($exception, 'responseHeader')) {
         $this->controller->response->header($exception->responseHeader());
     }
     $this->controller->response->statusCode($code);
     $viewVars = ['message' => $message, 'url' => h($url), 'error' => $unwrapped, 'code' => $code, '_serialize' => ['message', 'url', 'code']];
     if ($isDebug) {
         $viewVars['trace'] = Debugger::formatTrace($unwrapped->getTrace(), ['format' => 'array', 'args' => false]);
         $viewVars['_serialize'][] = 'trace';
     }
     $this->controller->set($viewVars);
     if ($unwrapped instanceof CakeException && $isDebug) {
         $this->controller->set($unwrapped->getAttributes());
     }
     return $this->_outputMessage($template);
 }
開發者ID:JesseDarellMoore,項目名稱:CS499,代碼行數:33,代碼來源:ExceptionRenderer.php

示例4: trace

 /**
  * Outputs a stack trace based on the supplied options.
  *
  * ### Options
  *
  * - `depth` - The number of stack frames to return. Defaults to 999
  * - `format` - The format you want the return. Defaults to the currently selected format. If
  *    format is 'array' or 'points' the return will be an array.
  * - `args` - Should arguments for functions be shown?  If true, the arguments for each method call
  *   will be displayed.
  * - `start` - The stack frame to start generating a trace from. Defaults to 0
  *
  * @param array $options Format for outputting stack trace.
  * @return mixed Formatted stack trace.
  * @link http://book.cakephp.org/3.0/en/development/debugging.html#generating-stack-traces
  */
 public static function trace(array $options = [])
 {
     return Debugger::formatTrace(debug_backtrace(), $options);
 }
開發者ID:JesseDarellMoore,項目名稱:CS499,代碼行數:20,代碼來源:Debugger.php


注:本文中的Cake\Error\Debugger::formatTrace方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。