From d2af852a6255a9732dec24066d5e16db07252363 Mon Sep 17 00:00:00 2001 From: Christian Schneider Date: Fri, 30 Nov 2007 14:48:14 +0000 Subject: Allow truncation of backtrace --- it_debug.class | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'it_debug.class') diff --git a/it_debug.class b/it_debug.class index 0d0dd07..8b3fd2a 100644 --- a/it_debug.class +++ b/it_debug.class @@ -168,7 +168,8 @@ function dump($args) } /** - * Print short stackdump + * Return short stackdump + * @param $p['levels'] number of stack levels to return (default: 0 = all) * @param $p['skiplevels'] number of stack levels to omit * @param $p['skipfiles'] regular expression of filenames to omit */ @@ -177,7 +178,7 @@ function backtrace($p = array()) if (!is_array($p)) $p = array('skiplevels' => $p); - $p += array('skiplevels'=> 0, 'skipfiles' => "###"); + $p += array('levels' => 0, 'skiplevels'=> 0, 'skipfiles' => "###"); if (!function_exists('memory_get_usage') || (memory_get_usage() < 50000000)) { @@ -187,6 +188,9 @@ function backtrace($p = array()) { $fn = (it::match('auto_prepend', $fn) ? basename(dirname($fn)) . "/" : "") . basename($fn); $result[] = $fn . ":" . $call['line']; + + if (--$p['levels'] == 0) + break; } } } -- cgit v1.2.3