Index: trunk/core/kernel/utility/debugger.php
===================================================================
diff -u -N -r4885 -r4971
--- trunk/core/kernel/utility/debugger.php (.../debugger.php) (revision 4885)
+++ trunk/core/kernel/utility/debugger.php (.../debugger.php) (revision 4971)
@@ -2,25 +2,25 @@
if( !class_exists('Debugger') ) {
class Debugger {
-
+
/**
* Set to true if fatal error occured
*
* @var bool
*/
var $IsFatalError = false;
-
+
/**
* Debugger data for building report
*
* @var Array
*/
var $Data = Array();
-
+
var $ProfilerData = Array();
var $ProfilerTotals = Array();
var $ProfilerTotalCount = Array();
-
+
/**
* Prevent recursion when processing debug_backtrace() function results
*
@@ -49,36 +49,36 @@
* @var string
*/
var $dummyImage = 'http://www.adamauto.lv/chevrolet/images/spacer.gif';
-
+
/**
* Temporary files created by debugger will be stored here
*
* @var string
*/
var $tempFolder = '';
-
+
/**
* Debug rows will be separated using this string before writing to debug file
*
* @var string
*/
var $rowSeparator = '@@';
-
+
/**
* Base URL for debugger includes
*
* @var string
*/
var $baseURL = '';
-
+
function Debugger()
{
global $start;
-
+
$this->InitDebugger();
$this->profileStart('kernel4_startup', 'Startup and Initialization of kernel4', $start);
$this->profileStart('script_runtime', 'Script runtime', $start);
-
+
ini_set('display_errors', $this->constOn('DBG_ZEND_PRESENT') ? 0 : 1); // show errors on screen in case if not in Zend Studio debugging
$this->scrollbarWidth = $this->isGecko() ? 22 : 25; // vertical scrollbar width differs in Firefox and other browsers
@@ -100,11 +100,11 @@
break;
}
}
-
+
$this->safeDefine('DBG_ZEND_PRESENT', 0); // set this constant value to 0 (zero) to debug debugger using Zend Studio
-
+
// set default values for debugger constants
- $dbg_constMap = Array(
+ $dbg_constMap = Array(
'DBG_USE_HIGHLIGHT' => 1, // highlight output same as php code using "highlight_string" function
'DBG_WINDOW_WIDTH' => 700, // set width of debugger window (in pixels) for better viewing large amount of debug data
'DBG_USE_SHUTDOWN_FUNC' => DBG_ZEND_PRESENT ? 0 : 1, // use shutdown function to include debugger code into output
@@ -114,54 +114,54 @@
'DOC_ROOT' => str_replace('\\', '/', realpath($_SERVER['DOCUMENT_ROOT']) ), // windows hack
'DBG_LOCAL_BASE_PATH' => 'w:' // replace DOC_ROOT in filenames (in errors) using this path
);
-
+
// only for IE, in case if no windows php script editor defined
if (!defined('DBG_EDITOR')) {
// $dbg_constMap['DBG_EDITOR'] = 'c:\Program Files\UltraEdit\uedit32.exe %F/%L';
$dbg_constMap['DBG_EDITOR'] = 'c:\Program Files\Zend\ZendStudio-5.2.0\bin\ZDE.exe %F';
- }
-
+ }
+
foreach ($dbg_constMap as $dbg_constName => $dbg_constValue) {
$this->safeDefine($dbg_constName, $dbg_constValue);
}
}
-
+
function constOn($const_name)
{
return defined($const_name) && constant($const_name);
}
-
+
function safeDefine($const_name, $const_value) {
if (!defined($const_name)) {
define($const_name, $const_value);
}
}
-
+
function InitReport()
{
if (!class_exists('kApplication')) return false;
-
+
$application =& kApplication::Instance();
-
+
// string used to separate debugger records while in file (used in debugger dump filename too)
$this->rowSeparator = '@'.$application->GetSID().'@';
-
+
// include debugger files from this url
$reg_exp = '/^'.preg_quote(FULL_PATH, '/').'/';
$kernel_path = preg_replace($reg_exp, '', KERNEL_PATH, 1);
$this->baseURL = PROTOCOL.SERVER_NAME.rtrim(BASE_PATH, '/').$kernel_path.'/utility/debugger';
-
+
// save debug output in this folder
$this->tempFolder = FULL_PATH.'/kernel/cache';
}
-
+
function mapLongError($msg)
{
$key = $this->generateID();
$this->longErrors[$key] = $msg;
return $key;
}
-
+
/**
* Appends all passed variable values (wihout variable names) to debug output
*
@@ -280,13 +280,13 @@
'kFactory',
'TemplateParser',
);
-
+
foreach ($skip_classes as $class_name) {
if (strtolower(get_class($object)) == strtolower($class_name)) {
return true;
}
}
-
+
return false;
}
@@ -360,7 +360,7 @@
if (!$this->constOn('DBG_USE_HIGHLIGHT')) {
return $string;
}
-
+
$string = str_replace( Array('\\', '/') , Array('_no_match_string_', '_n_m_s_'), $string);
$string = highlight_string('', true);
$string = str_replace( Array('_no_match_string_', '_n_m_s_'), Array('\\', '/'), $string);
@@ -410,7 +410,7 @@
{
return str_replace(DOC_ROOT, DBG_LOCAL_BASE_PATH, $remoteFile);
}
-
+
/**
* Appends call trace till this method call
*
@@ -429,7 +429,7 @@
}
$this->appendHTML('Memory usage '.$msg.' '.$used.'Kb');
}
-
+
/**
* Appends HTML code whithout transformations
*
@@ -459,11 +459,11 @@
case 'append':
$this->Data[$index]['html'] .= '
'.$html;
break;
-
+
case 'prepend':
$this->Data[$index]['html'] = $this->Data[$index]['html'].'
'.$html;
break;
-
+
case 'replace':
$this->Data[$index]['html'] = $html;
break;
@@ -573,7 +573,7 @@
$this->ProfilerTotals[$total_key] = 0;
$this->ProfilerTotalCount[$total_key] = 0;
}
-
+
if (!isset($value)) {
$value = $this->ProfilerData[$key]['ends'] - $this->ProfilerData[$key]['begins'];
}
@@ -617,47 +617,47 @@
'Warning' => Array(E_WARNING, E_USER_WARNING),
'Notice' => Array(E_NOTICE, E_USER_NOTICE),
);
-
+
if (defined('E_STRICT')) {
$error_map['PHP5 Strict'] = Array(E_STRICT);
}
-
+
foreach ($error_map as $error_name => $error_codes) {
if (in_array($error_code, $error_codes)) {
return $error_name;
}
}
-
+
return '';
}
-
+
/**
* Generates report
*
*/
function printReport($returnResult = false, $clean_output_buffer = true)
{
$this->profileFinish('script_runtime');
-
+
$this->breakOutofBuffering();
if ($this->reportDone) {
// don't print same report twice
return '';
}
-
+
if ($this->constOn('DBG_SKIP_REPORTING') || $this->constOn('DBG_ZEND_PRESENT')) return '';
-
+
$debugger_start = memory_get_usage();
-
+
if (defined('SPACER_URL')) {
$this->dummyImage = SPACER_URL;
}
-
+
$this->InitReport(); // set parameters required by AJAX
-
+
// defined here, because user can define this contant while script is running, not event before debugger is started
$this->safeDefine('DBG_RAISE_ON_WARNINGS', 0);
-
+
$this->appendSession(); // show php session if any
// ensure, that 1st line of debug output always is this one:
@@ -678,7 +678,7 @@
// detailed memory usage reporting by objects was enabled -> show totals
$this->appendHTML('Memory used by Objects: '.round($this->ProfilerTotals['objects'] / 1024, 2).'Kb');
}
-
+
/*if ($this->constOn('DBG_INCLUDED_FILES')) {
$files = get_included_files();
$this->appendHTML('Included files:');
@@ -711,10 +711,10 @@
$this->appendHTML('Grand Total: '.' Mem: '.sprintf("%.4f Kb", ($totals['mem']+$totals_configs['mem'])/1024).' Time: '.sprintf("%.4f", $totals['time']+$totals_configs['time']));
}
}*/
-
+
$debug_file = $this->tempFolder.'/debug_'.$this->rowSeparator.'.txt';
if (file_exists($debug_file)) unlink($debug_file);
-
+
$i = 0;
$fp = fopen($debug_file, 'a');
$lineCount = count($this->Data);
@@ -725,6 +725,7 @@
fclose($fp);
ob_start();
?>
+