From fbfcbee45d7f932570a2b8a2d22325bdad3ddb8a Mon Sep 17 00:00:00 2001 From: Robert Sesek Date: Sat, 21 Jan 2006 20:51:30 +0000 Subject: [PATCH] - Added ISSO->format_debug_trace() so that we can format debug_backtrace() anywhere - DB::query() now stores much more information about each query --- db.php | 5 ++++- kernel.php | 36 +++++++++++++++++++++++++++--------- printer.php | 2 +- 3 files changed, 32 insertions(+), 11 deletions(-) diff --git a/db.php b/db.php index 61fb95d..f80e2fb 100644 --- a/db.php +++ b/db.php @@ -212,9 +212,10 @@ class DB_Abstract */ function query($string) { + $time = microtime(); + $this->querystr = $string; $this->result = call_user_func($this->commands['query'], $this->dblink, $string); - $this->history[] = $string; if (defined('ISSO_SHOW_QUERIES_LIVE')) { @@ -229,6 +230,8 @@ class DB_Abstract $this->error('Invalid SQL query'); } + $this->history[] = array('query' => $string, 'time' => $this->registry->modules['functions']->fetch_microtime_diff($time), 'trace' => $this->registry->format_debug_trace(debug_backtrace())); + return $this->result; } diff --git a/kernel.php b/kernel.php index effbefc..7aed66c 100644 --- a/kernel.php +++ b/kernel.php @@ -689,15 +689,7 @@ class ISSO array_shift($backtrace); } - $trace = array(); - foreach ($backtrace AS $i => $step) - { - $file = $step['file'] . ':' . $step['line']; - $funct = (isset($step['class']) ? $step['class'] . '::' . $step['function'] : $step['function']); - $args = (is_array($step['args']) ? implode(', ', $step['args']) : ''); - - $trace[] = "#$i $funct($args) called at [$file]"; - } + $trace = $this->format_debug_trace($backtrace); $output = "\n
\n"; $output .= "\n\n\t\n"; @@ -715,6 +707,32 @@ class ISSO } } + // ################################################################### + /** + * Prepares a debug_backtrace() array for output to the browser by + * compressing the array into visible text + * + * @access public + * + * @param array debug_backtrace() array + * + * @return array Formatted trace output + */ + function format_debug_trace($backtrace) + { + $trace = array(); + foreach ($backtrace AS $i => $step) + { + $file = $step['file'] . ':' . $step['line']; + $funct = (isset($step['class']) ? $step['class'] . '::' . $step['function'] : $step['function']); + $args = (is_array($step['args']) ? implode(', ', $step['args']) : ''); + + $trace[] = "#$i $funct($args) called at [$file]"; + } + + return $trace; + } + // ################################################################### /** * Custom error handler for ISSO; only handle E_WARNING, E_NOTICE, diff --git a/printer.php b/printer.php index 1aa03ff..49ad720 100644 --- a/printer.php +++ b/printer.php @@ -400,7 +400,7 @@ JS; echo '
';
 				foreach ($this->registry->modules[ISSO_DB_LAYER]->history AS $query)
 				{
-					echo $query . "\n\n
\n\n"; + echo print_r($query, true) . "\n\n
\n\n"; } echo '
'; } -- 2.43.5
$prefix: $title