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 ($CFG->debug >= $level) {
if ($message) { if ($message) {
$caller = debug_backtrace(); $callers = debug_backtrace();
$caller = $caller[0]; $from = '<ul style="text-align: left">';
$from = " in $caller[file] on line $caller[line]"; foreach ($callers as $caller) {
if (isset($caller['function'])) { $from .= '<li>line ' . $caller['line'] . ' of ' . substr($caller['file'], strlen($CFG->dirroot) + 1);
$from .= " in $caller[function]()"; if (isset($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)) { if (!isset($CFG->debugdisplay)) {
$CFG->debugdisplay = ini_get('display_errors'); $CFG->debugdisplay = ini_get('display_errors');
} }