From d7177f246e63afb2777eb8418cc4e5e3c17e9698 Mon Sep 17 00:00:00 2001 From: Christian Schneider Date: Fri, 21 Sep 2007 15:27:13 +0000 Subject: Streamline dumping of debug info --- it.class | 10 ++++------ it_debug.class | 14 ++++++++++---- 2 files changed, 14 insertions(+), 10 deletions(-) diff --git a/it.class b/it.class index 226a88d..eb3cafe 100644 --- a/it.class +++ b/it.class @@ -99,7 +99,7 @@ function error($p = array(), $body = "", $to = "") $p = array(); } - $p += array('timewindow' => 25*3600, 'graceperiod' => 60); + $p += array('timewindow' => 25*3600, 'graceperiod' => 60, 'backtraceskip' => 0); if (!$to) $to = strtr(trim(@file_get_contents($GLOBALS['ULTRAHOME'] . "/.diffnotice")), array("\n"=>',', ' '=>'')); @@ -134,12 +134,9 @@ function error($p = array(), $body = "", $to = "") $title="Error in $url"; if (!function_exists('memory_get_usage') || (memory_get_usage() < 50000000)) - { - $trace = "\n\nTrace: " . it_debug::backtrace(); - $stack = "\n\nStack:\n" . print_r(debug_backtrace(), true); - } + $trace = "\n\nTrace: " . it_debug::backtrace($p['backtraceskip']); - $body .= "\nUrl: $url$trace\n\n\$_REQUEST: ".print_r($_REQUEST, true) . "\n\$_SERVER: " . print_r($_SERVER, true) . $stack; + $body .= "\nUrl: $url$trace"; if (!ereg('live', $GLOBALS['ULTRASERVERTYPE'])) { @@ -152,6 +149,7 @@ function error($p = array(), $body = "", $to = "") EDC('exec', $cmd); if (($pipe = popen($cmd, "w"))) { + $body .= "\n\nLocals" . print_r($p['locals'], true) . "\n\n\$_REQUEST: ".print_r($_REQUEST, true) . "\n\$_SERVER: " . print_r($_SERVER, true) . "\n\nStack:\n" . print_r(debug_backtrace(), true); fputs($pipe, $body); pclose($pipe); } diff --git a/it_debug.class b/it_debug.class index 61b4889..5069185 100644 --- a/it_debug.class +++ b/it_debug.class @@ -127,11 +127,17 @@ function dump($args) return "$r\n"; } -function backtrace() +function backtrace($skip = 0) { - foreach (array_slice(debug_backtrace(), 1) as $call) - $line .= basename($call['file']) . ":" . $call['line'] . " "; - return $line; + $result = array(); + + foreach (array_slice(debug_backtrace(), $skip + 1) as $call) + { + if ($call['file']) + $result[] = basename($call['file']) . ":" . $call['line']; + } + + return join(" ", $result); } } -- cgit v1.2.3