Browse Source

Added a useful function for debugging: DebugBacktrace which provides a "light" version of PHP's built-in debug_backtrace().

git-svn-id: http://svn.code.sf.net/p/itop/code/trunk@1392 a333f486-631f-4898-b8df-5754b55c2be0
dflaven 14 years ago
parent
commit
d6ba7c611b
1 changed files with 11 additions and 0 deletions
  1. 11 0
      application/utils.inc.php

+ 11 - 0
application/utils.inc.php

@@ -504,5 +504,16 @@ class utils
 			}			
 			}			
 		}
 		}
 	 }
 	 }
+	 
+	 static function DebugBacktrace($iLimit = 5)
+	 {
+		$aFullTrace = debug_backtrace();
+		$aLightTrace = array();
+		for($i=1; ($i<=$iLimit && $i < count($aFullTrace)); $i++) // Skip the last function call... which is the call to this function !
+		{
+			$aLightTrace[$i] = $aFullTrace[$i]['function'].'(), called from line '.$aFullTrace[$i]['line'].' in '.$aFullTrace[$i]['file'];
+		}
+		echo "<p><pre>".print_r($aLightTrace, true)."</pre></p>\n";
+	 }
 }
 }
 ?>
 ?>