Hoa central
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
Hoa\Log\Backtrace\Backtrace Class Reference

Public Member Functions

 __construct ()
 
 debug ()
 
 getTree ()
 
 __toString ()
 

Protected Member Functions

 computeTree (Array $array=array())
 

Protected Attributes

 $_tree = null
 

Detailed Description

Class .

Build a backtrace tree. Please, read the API documentation of the class attributes to well-understand. A DOT output is available.

Author
Ivan Enderlin ivan..nosp@m.ende.nosp@m.rlin@.nosp@m.hoa-.nosp@m.proje.nosp@m.ct.n.nosp@m.et

Definition at line 72 of file Backtrace.php.

Constructor & Destructor Documentation

Hoa\Log\Backtrace\Backtrace::__construct ( )

Build an empty backtrace tree, and set the root.

public

Returns
void

Definition at line 89 of file Backtrace.php.

89  {
90 
91  $this->_tree = new \Hoa\Tree(
92  new Node(array(
93  'function' => 'Bootstrap',
94  'line' => 42,
95  'file' => 'BigBlackHole',
96  'class' => null,
97  'object' => null,
98  'type' => null,
99  'args' => null
100  ))
101  );
102 
103  return;
104  }

Member Function Documentation

Hoa\Log\Backtrace\Backtrace::__toString ( )

Print the tree in DOT language.

public

Returns
string

Definition at line 175 of file Backtrace.php.

175  {
176 
177  $out = new \Hoa\Tree\Visitor\Dot();
178 
179  return $out->visit($this->getTree());
180  }

Here is the call graph for this function:

Hoa\Log\Backtrace\Backtrace::computeTree ( Array  $array = array())
protected

Compute the tree with a backtrace stack.

protected

Parameters
array$arrayBacktrace stack.
Returns
void

Definition at line 113 of file Backtrace.php.

113  {
114 
115  $node = null;
116  $child = null;
117  $currentNode = $this->_tree;
118 
119  foreach($array as $i => $trace) {
120 
121  $node = new Node($trace);
122 
123  if(true === $currentNode->childExists($node->getId()))
124  $currentNode = $currentNode->getChild($node->getId());
125  else {
126 
127  $child = new \Hoa\Tree($node);
128  $currentNode->insert($child);
129  $currentNode = $child;
130  }
131  }
132 
133  return;
134  }

Here is the caller graph for this function:

Hoa\Log\Backtrace\Backtrace::debug ( )

Run a debug trace, i.e. build a new branche in the backtrace tree.

public

Returns
void

Definition at line 142 of file Backtrace.php.

142  {
143 
144  $array = debug_backtrace();
145  array_shift($array); // \Hoa\Log\Backtrace::debug().
146 
147  if(isset($array[0]['class']) && $array[0]['class'] == 'Hoa\Log\Log')
148  array_shift($array); // Hoa\Log::log().
149 
150  if(isset($array[0]['function']) && $array[0]['function'] == 'hlog')
151  array_shift($array); // hlog().
152 
153  $this->computeTree(array_reverse($array));
154 
155  return;
156  }
computeTree(Array $array=array())
Definition: Backtrace.php:113

Here is the call graph for this function:

Hoa\Log\Backtrace\Backtrace::getTree ( )

Get the backtrace tree.

public

Returns
array

Definition at line 164 of file Backtrace.php.

164  {
165 
166  return $this->_tree;
167  }

Here is the caller graph for this function:

Member Data Documentation

Hoa\Log\Backtrace\Backtrace::$_tree = null
protected

Definition at line 79 of file Backtrace.php.


The documentation for this class was generated from the following file: