Make debugging more helpful by printing a full stack trace.

This commit is contained in:
tjhunt 2007-03-22 16:43:48 +00:00
parent cb6a4f09ee
commit 6fd3300925

View file

@ -5756,12 +5756,20 @@ function debugging($message='', $level=DEBUG_NORMAL) {
if ($CFG->debug >= $level) {
if ($message) {
$caller = debug_backtrace();
$caller = $caller[0];
$from = " in $caller[file] on line $caller[line]";
$callers = debug_backtrace();
$from = '<ul style="text-align: left">';
foreach ($callers as $caller) {
$from .= '<li>line ' . $caller['line'] . ' of ' . substr($caller['file'], strlen($CFG->dirroot) + 1);
if (isset($caller['function'])) {
$from .= " in $caller[function]()";
$from .= ': call to ';
if (isset($caller['class'])) {
$from .= $caller['class'] . $caller['type'];
}
$from .= $caller['function'] . '()';
}
$from .= '</li>';
}
$from .= '</ul>';
if (!isset($CFG->debugdisplay)) {
$CFG->debugdisplay = ini_get('display_errors');
}