Index: trunk/tools/debug_sample.php
===================================================================
diff -u -r842 -r854
--- trunk/tools/debug_sample.php (.../debug_sample.php) (revision 842)
+++ trunk/tools/debug_sample.php (.../debug_sample.php) (revision 854)
@@ -10,9 +10,12 @@
//define('SQL_TO_SCREEN', 1); // output sql queries to screen
+
+ define('SQL_ERROR_DIE', 1);
+ //define('SQL_PROFILE', 1);
+
// sql logging to file
define('SQL_TO_FILE', 1); // output sql queries to file
- define('SQL_ERROR_DIE', 1);
define('SQL_OUTPUT', DOC_ROOT.'/inportal_sqls.txt'); // file where to store sql queries
define('SQL_OVERWRITE', 1); // overwrite or not sql_log file
@@ -24,31 +27,33 @@
define('DEBUG_ACTIONS', SHOW_REQUEST + FRONT_SHOW_REQUEST);
//define('DEBUG_HELP', 1); // allow to add missing help
- // For local license testing
- //define('GET_LICENSE_URL', 'http://maris.prod.intechnic.lv/in-business/license.php');
-
if( defined('DEBUG_MODE') && constant('DEBUG_MODE') == 1 )
{
ini_set('display_errors', 1);
}
- function SQLLog($msg, $newline = true)
+ function isSkipTable($sql)
{
- static $file_reset = false;
-
- $db =& GetADODBConnection();
- // telestial specific: begin
- static $prefix = '';
- $prefix = GetTablePrefix();
- // 'Theme'
- $skip_tables = Array( 'Modules','Language','PermissionConfig','PermCache',
+ static $skipTables = Array('Modules','Language','PermissionConfig','PermCache',
'SessionData','UserSession','Phrase','ConfigurationValues',
'PersistantSessionData','Events','EmailQueue',
'Permissions');
- foreach($skip_tables as $table)
- if( strpos($msg, $prefix.$table) !== false ) return false;
- // telestial specific: end
+ static $prefix = '';
+ $prefix = GetTablePrefix();
+ foreach($skipTables as $table)
+ {
+ if( strpos($sql, $prefix.$table) !== false ) return true;
+ }
+ return false;
+ }
+
+ function SQLLog($msg, $newline = true)
+ {
+ static $file_reset = false;
+ $db =& GetADODBConnection();
+ if( isSkipTable($msg) ) return false;
+
$select_pos = strpos($msg, 'SELECT ');
if($select_pos !== false)
{
Index: trunk/kernel/include/adodb/adodb.inc.php
===================================================================
diff -u -r842 -r854
--- trunk/kernel/include/adodb/adodb.inc.php (.../adodb.inc.php) (revision 842)
+++ trunk/kernel/include/adodb/adodb.inc.php (.../adodb.inc.php) (revision 854)
@@ -723,8 +723,15 @@
ADOConnection::outp( "=----\n($this->databaseType): ".($sqlTxt)." \n-----\n",false);
flush();
+ $profileSQLs = defined('SQL_PROFILE')&&(SQL_PROFILE==1);
+ if($profileSQLs)
+ {
+ $isSkipTable = isSkipTable($sql);
+ $queryID = $debugger->generateID();
+ if(!$isSkipTable) $debugger->profileStart('sql_'.$queryID,$sql);
+ }
$this->_queryID = $this->_query($sql,$inputarr,$arg3);
-
+ if($profileSQLs && !$isSkipTable) $debugger->profileFinish('sql_'.$queryID);
/*
Alexios Fakios notes that ErrorMsg() must be called before ErrorNo() for mssql
because ErrorNo() calls Execute('SELECT @ERROR'), causing recure
Index: trunk/kernel/include/debugger.php
===================================================================
diff -u -r842 -r854
--- trunk/kernel/include/debugger.php (.../debugger.php) (revision 842)
+++ trunk/kernel/include/debugger.php (.../debugger.php) (revision 854)
@@ -69,7 +69,8 @@
case 'profiler':
$profileKey = $Data['profile_key'];
$Data =& $this->ProfilerData[$profileKey];
- return 'Name: '.$Data['description'].'. Runtime: '.($Data['ends'] - $Data['begins']);
+ $runtime = ($Data['ends'] - $Data['begins']); // in seconds
+ return 'Name: '.$Data['description'].'. Runtime: '.$runtime.'s';
break;
default:
@@ -103,15 +104,39 @@
function profileStart($key, $description)
{
- $this->ProfilerData[$key] = Array('begins' => time(), 'debuggerRowID' => count($this->Data), 'description' => $description);
+ $timeStamp = $this->getMoment();
+ $this->ProfilerData[$key] = Array('begins' => $timeStamp, 'ends' => 5000, 'debuggerRowID' => count($this->Data), 'description' => $description);
$this->Data[] = array('profile_key' => $key, 'debug_type' => 'profiler');
}
function profileFinish($key)
{
- $this->ProfilerData[$key]['ends'] = time();
+ $this->ProfilerData[$key]['ends'] = $this->getMoment();
}
+ function getMoment()
+ {
+ list($usec, $sec) = explode(' ', microtime());
+ return ((float)$usec + (float)$sec);
+ }
+
+ function generateID()
+ {
+ list($usec, $sec) = explode(" ",microtime());
+
+ $id_part_1 = substr($usec, 4, 4);
+ $id_part_2 = mt_rand(1,9);
+ $id_part_3 = substr($sec, 6, 4);
+ $digit_one = substr($id_part_1, 0, 1);
+ if ($digit_one == 0) {
+ $digit_one = mt_rand(1,9);
+ $id_part_1 = ereg_replace("^0","",$id_part_1);
+ $id_part_1=$digit_one.$id_part_1;
+ }
+ return $id_part_1.$id_part_2.$id_part_3;
+ }
+
+
function getErrorNameByCode($errorCode)
{
switch($errorCode)