trace() 공개 정적인 메소드

Outputs a stack trace based on the supplied options.
public static trace ( array $options = [] ) : string | array | null
$options array Format for outputting stack trace. Available options are: - `'args'`: A boolean indicating if arguments should be included. - `'depth'`: The maximum depth of the trace. - `'format'`: Either `null`, `'points'` or `'array'`. - `'includeScope'`: A boolean indicating if items within scope should be included. - `'scope'`: Scope for items to include. - `'start'`: The depth to start with. - `'trace'`: A trace to use instead of generating one.
리턴 string | array | null Stack trace formatted according to `'format'` option.
예제 #1
0
 public static function __callStatic($priority = 'debug', $params = array())
 {
     $trace = Debugger::trace(array('format' => 'array', 'depth' => 3, 'includeScope' => false));
     $trace = $trace[2];
     if (empty($trace)) {
         throw UnexpectedValueException('Could not trace method');
     }
     $trace = array('method' => $trace['functionRef'], 'line' => $trace['line'], 'file' => $trace['file']);
     $message = "//////////// {$trace['file']}:{$trace['line']} -> {$trace['method']} ////////////\n";
     foreach ($params as $param) {
         $dump = Debugger::export($param);
         $message = "{$message}{$dump}\n";
     }
     return parent::write($priority, $message);
 }
예제 #2
0
파일: Unit.php 프로젝트: unionofrad/lithium
 /**
  * Convert an exception object to an exception result array for test reporting.
  *
  * @param array $exception The exception data to report on. Statistics are gathered and
  *               added to the reporting stack contained in `Unit::$_results`.
  * @param string $lineFlag
  * @return void
  * @todo Refactor so that reporters handle trace formatting.
  */
 protected function _reportException($exception, $lineFlag = null)
 {
     $message = $exception['message'];
     $isExpected = ($exp = end($this->_expected)) && ($exp === true || $exp === $message || Validator::isRegex($exp) && preg_match($exp, $message));
     if ($isExpected) {
         return array_pop($this->_expected);
     }
     $initFrame = current($exception['trace']) + array('class' => '-', 'function' => '-');
     foreach ($exception['trace'] as $frame) {
         if (isset($scopedFrame)) {
             break;
         }
         if (!class_exists('lithium\\analysis\\Inspector')) {
             continue;
         }
         if (isset($frame['class']) && in_array($frame['class'], Inspector::parents($this))) {
             $scopedFrame = $frame;
         }
     }
     if (class_exists('lithium\\analysis\\Debugger')) {
         $exception['trace'] = Debugger::trace(array('trace' => $exception['trace'], 'format' => '{:functionRef}, line {:line}', 'includeScope' => false, 'scope' => array_filter(array('functionRef' => __NAMESPACE__ . '\\{closure}', 'line' => $lineFlag))));
     }
     $this->_result('exception', $exception + array('class' => $initFrame['class'], 'method' => $initFrame['function']));
 }
예제 #3
0
 * @license       http://opensource.org/licenses/bsd-license.php The BSD License
 */
use lithium\analysis\Debugger;
use lithium\analysis\Inspector;
$exception = $info['exception'];
$replace = array('&lt;?php', '?&gt;', '<code>', '</code>', "\n");
$context = 5;
/**
 * Set Lithium-esque colors for syntax highlighing.
 */
ini_set('highlight.string', '#4DDB4A');
ini_set('highlight.comment', '#D42AAE');
ini_set('highlight.keyword', '#D42AAE');
ini_set('highlight.default', '#3C96FF');
ini_set('highlight.htm', '#FFFFFF');
$stack = Debugger::trace(array('format' => 'array', 'trace' => $exception->getTrace()));
array_unshift($stack, array('functionRef' => '[exception]', 'file' => $exception->getFile(), 'line' => $exception->getLine()));
?>
<h3>Exception</h3>

<div class="lithium-exception-class">
    <?php 
echo get_class($exception);
?>

    <?php 
if ($code = $exception->getCode()) {
    ?>
        <span class="code">(code <?php 
    echo $code;
    ?>
예제 #4
0
 /**
  * Convert an exception object to an exception result array for test reporting.
  *
  * @param object $exception The exception object to report on. Statistics are gathered and
  *               added to the reporting stack contained in `Unit::$_results`.
  * @param string $lineFlag
  * @return void
  * @todo Refactor so that reporters handle trace formatting.
  */
 protected function _reportException($exception, $lineFlag = null)
 {
     $initFrame = current($exception['trace']) + array('class' => '-', 'function' => '-');
     foreach ($exception['trace'] as $frame) {
         if (isset($scopedFrame)) {
             break;
         }
         if (!class_exists('lithium\\analysis\\Inspector')) {
             continue;
         }
         if (isset($frame['class']) && in_array($frame['class'], Inspector::parents($this))) {
             $scopedFrame = $frame;
         }
     }
     $trace = $exception['trace'];
     unset($exception['trace']);
     $this->_result('exception', $exception + array('class' => $initFrame['class'], 'method' => $initFrame['function'], 'trace' => Debugger::trace(array('trace' => $trace, 'format' => '{:functionRef}, line {:line}', 'includeScope' => false, 'scope' => array_filter(array('functionRef' => __NAMESPACE__ . '\\{closure}', 'line' => $lineFlag))))));
 }