From 5d201ba6e58dee377303ae8f320c554cc0505c1b Mon Sep 17 00:00:00 2001 From: Urban Müller Date: Thu, 29 Nov 2007 18:41:17 +0000 Subject: allow skipping of library filenames --- it_debug.class | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) (limited to 'it_debug.class') diff --git a/it_debug.class b/it_debug.class index 22f0d5a..0d0dd07 100644 --- a/it_debug.class +++ b/it_debug.class @@ -169,17 +169,21 @@ function dump($args) /** * Print short stackdump - * @param $skip number of stack levels to omip + * @param $p['skiplevels'] number of stack levels to omit + * @param $p['skipfiles'] regular expression of filenames to omit */ -function backtrace($skip = 0) +function backtrace($p = array()) { - $result = array(); + if (!is_array($p)) + $p = array('skiplevels' => $p); + + $p += array('skiplevels'=> 0, 'skipfiles' => "###"); if (!function_exists('memory_get_usage') || (memory_get_usage() < 50000000)) { - foreach (array_slice(debug_backtrace(), $skip + 1) as $call) + foreach (array_slice(debug_backtrace(), $p['skiplevels'] + 1) as $call) { - if (($fn = $call['file'])) + if (($fn = $call['file']) && !it::match($p['skipfiles'], $call['file'])) { $fn = (it::match('auto_prepend', $fn) ? basename(dirname($fn)) . "/" : "") . basename($fn); $result[] = $fn . ":" . $call['line']; @@ -187,7 +191,7 @@ function backtrace($skip = 0) } } - return join(" ", $result); + return join(" ", (array)$result); } } -- cgit v1.2.3