mirror of
https://github.com/Lastorder-DC/rhymix.git
synced 2026-05-02 08:42:15 +09:00
Finalize debug data format and allow all statistics to be collected
This commit is contained in:
parent
8394afce74
commit
ac8460d782
10 changed files with 140 additions and 141 deletions
|
|
@ -372,13 +372,13 @@ class DB
|
|||
{
|
||||
if($call['function'] == 'executeQuery' || $call['function'] == 'executeQueryArray')
|
||||
{
|
||||
$log['backtrace'] = array_slice($bt, $no);
|
||||
$call_no = $no;
|
||||
$call_no++;
|
||||
$log['called_file'] = $bt[$call_no]['file'];
|
||||
$log['called_line'] = $bt[$call_no]['line'];
|
||||
$call_no++;
|
||||
$log['called_method'] = $bt[$call_no]['class'].$bt[$call_no]['type'].$bt[$call_no]['function'];
|
||||
$log['backtrace'] = array_slice($bt, $call_no, 1);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@
|
|||
*/
|
||||
class DisplayHandler extends Handler
|
||||
{
|
||||
|
||||
public static $response_size = 0;
|
||||
var $content_size = 0; // /< The size of displaying contents
|
||||
var $gz_enabled = FALSE; // / <a flog variable whether to call contents after compressing by gzip
|
||||
var $handler = NULL;
|
||||
|
|
@ -81,7 +81,6 @@ class DisplayHandler extends Handler
|
|||
Context::getInstance()->checkSessionStatus();
|
||||
|
||||
// header output
|
||||
|
||||
$httpStatusCode = $oModule->getHttpStatusCode();
|
||||
if($httpStatusCode && $httpStatusCode != 200)
|
||||
{
|
||||
|
|
@ -119,16 +118,14 @@ class DisplayHandler extends Handler
|
|||
ini_set('zlib.output_compression', true);
|
||||
}
|
||||
|
||||
// results directly output
|
||||
print $output;
|
||||
$this->content_size = strlen($output);
|
||||
|
||||
// call a trigger after display
|
||||
self::$response_size = $this->content_size = strlen($output);
|
||||
ModuleHandler::triggerCall('display', 'after', $output);
|
||||
|
||||
// debugOutput output
|
||||
$this->content_size = strlen($output);
|
||||
print $this->getDebugInfo($output);
|
||||
$debug = $this->getDebugInfo($output);
|
||||
print $output;
|
||||
print $debug;
|
||||
|
||||
flushSlowlog();
|
||||
}
|
||||
|
|
@ -145,6 +142,8 @@ class DisplayHandler extends Handler
|
|||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// Check if debugging info should be visible to the current user.
|
||||
$display_to = config('debug.display_to');
|
||||
switch ($display_to)
|
||||
{
|
||||
|
|
@ -172,19 +171,16 @@ class DisplayHandler extends Handler
|
|||
return;
|
||||
}
|
||||
|
||||
// Set some useful variables.
|
||||
$basedir_len = strlen(RX_BASEDIR);
|
||||
$timestamp = sprintf('[%s]', Rhymix\Framework\DateTime::formatTimestampForCurrentUser('Y-m-d H:i:s P', RX_TIME));
|
||||
|
||||
// Collect debug information.
|
||||
$entries = Rhymix\Framework\Debug::getEntries();
|
||||
$errors = config('debug.log_errors') ? Rhymix\Framework\Debug::getErrors() : null;
|
||||
$queries = config('debug.log_queries') ? Rhymix\Framework\Debug::getQueries() : null;
|
||||
|
||||
// Print debug information.
|
||||
switch ($display_type = config('debug.display_type'))
|
||||
{
|
||||
case 'panel':
|
||||
$data = Rhymix\Framework\Debug::getDebugData();
|
||||
$json_options = defined('JSON_PRETTY_PRINT') ? (JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE) : 0;
|
||||
$panel_html = '<div id="rhymix_debug_panel"></div>';
|
||||
$panel_script = 'var rhymix_debug_content = ' . json_encode($data, $json_options) . ';';
|
||||
$replace_html = '<div id="rhymix_debug_panel">' . "\n" . '<script>' . "\n" . $panel_script . "\n" . '</script>' . "\n" . '</div>';
|
||||
$output = str_replace($panel_html, $replace_html, $output);
|
||||
break;
|
||||
|
||||
case 'comment':
|
||||
|
|
@ -195,6 +191,7 @@ class DisplayHandler extends Handler
|
|||
return;
|
||||
}
|
||||
ob_start();
|
||||
$data = Rhymix\Framework\Debug::getDebugData();
|
||||
include RX_BASEDIR . 'common/tpl/debug_comment.html';
|
||||
$content = ob_get_clean();
|
||||
if ($display_type === 'file')
|
||||
|
|
|
|||
|
|
@ -86,10 +86,7 @@ class HTMLDisplayHandler
|
|||
|
||||
if(Context::get('layout') != 'none')
|
||||
{
|
||||
if(__DEBUG__ == 3)
|
||||
{
|
||||
$start = microtime(true);
|
||||
}
|
||||
$start = microtime(true);
|
||||
|
||||
Context::set('content', $output, false);
|
||||
|
||||
|
|
@ -142,10 +139,7 @@ class HTMLDisplayHandler
|
|||
$pathInfo = pathinfo($layout_file);
|
||||
$onlyLayoutFile = $pathInfo['filename'];
|
||||
|
||||
if(__DEBUG__ == 3)
|
||||
{
|
||||
$GLOBALS['__layout_compile_elapsed__'] = microtime(true) - $start;
|
||||
}
|
||||
$GLOBALS['__layout_compile_elapsed__'] = microtime(true) - $start;
|
||||
|
||||
if(stripos($_SERVER['HTTP_USER_AGENT'], 'MSIE') !== FALSE && (Context::get('_use_ssl') == 'optional' || Context::get('_use_ssl') == 'always'))
|
||||
{
|
||||
|
|
@ -168,10 +162,7 @@ class HTMLDisplayHandler
|
|||
return;
|
||||
}
|
||||
|
||||
if(__DEBUG__ == 3)
|
||||
{
|
||||
$start = microtime(true);
|
||||
}
|
||||
$start = microtime(true);
|
||||
|
||||
// move <style ..></style> in body to the header
|
||||
$output = preg_replace_callback('!<style(.*?)>(.*?)<\/style>!is', array($this, '_moveStyleToHeader'), $output);
|
||||
|
|
@ -218,10 +209,7 @@ class HTMLDisplayHandler
|
|||
$output = preg_replace_callback('@<textarea[^>]*\sname="' . $keys . '".+</textarea>@isU', array(&$this, '_preserveTextAreaValue'), $output);
|
||||
}
|
||||
|
||||
if(__DEBUG__ == 3)
|
||||
{
|
||||
$GLOBALS['__trans_content_elapsed__'] = microtime(true) - $start;
|
||||
}
|
||||
$GLOBALS['__trans_content_elapsed__'] = microtime(true) - $start;
|
||||
|
||||
// Remove unnecessary information
|
||||
$output = preg_replace('/member\_\-([0-9]+)/s', 'member_0', $output);
|
||||
|
|
|
|||
|
|
@ -42,16 +42,13 @@ class TemplateHandler
|
|||
{
|
||||
static $oTemplate = NULL;
|
||||
|
||||
if(__DEBUG__ == 3)
|
||||
if(!isset($GLOBALS['__TemplateHandlerCalled__']))
|
||||
{
|
||||
if(!isset($GLOBALS['__TemplateHandlerCalled__']))
|
||||
{
|
||||
$GLOBALS['__TemplateHandlerCalled__'] = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
$GLOBALS['__TemplateHandlerCalled__']++;
|
||||
}
|
||||
$GLOBALS['__TemplateHandlerCalled__'] = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
$GLOBALS['__TemplateHandlerCalled__']++;
|
||||
}
|
||||
|
||||
if(!$oTemplate)
|
||||
|
|
@ -118,10 +115,7 @@ class TemplateHandler
|
|||
public function compile($tpl_path, $tpl_filename, $tpl_file = '')
|
||||
{
|
||||
// store the starting time for debug information
|
||||
if(__DEBUG__ == 3)
|
||||
{
|
||||
$start = microtime(true);
|
||||
}
|
||||
$start = microtime(true);
|
||||
|
||||
// initiation
|
||||
$this->init($tpl_path, $tpl_filename, $tpl_file);
|
||||
|
|
@ -155,10 +149,7 @@ class TemplateHandler
|
|||
}
|
||||
|
||||
// store the ending time for debug information
|
||||
if(__DEBUG__ == 3)
|
||||
{
|
||||
$GLOBALS['__template_elapsed__'] += microtime(true) - $start;
|
||||
}
|
||||
$GLOBALS['__template_elapsed__'] += microtime(true) - $start;
|
||||
|
||||
return $output;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -89,10 +89,7 @@ class XmlParser
|
|||
function parse($input = '', $arg1 = NULL, $arg2 = NULL)
|
||||
{
|
||||
// Save the compile starting time for debugging
|
||||
if(__DEBUG__ == 3)
|
||||
{
|
||||
$start = microtime(true);
|
||||
}
|
||||
$start = microtime(true);
|
||||
|
||||
$this->lang = Context::getLangType();
|
||||
|
||||
|
|
@ -141,10 +138,7 @@ class XmlParser
|
|||
|
||||
$output = array_shift($this->output);
|
||||
// Save compile starting time for debugging
|
||||
if(__DEBUG__ == 3)
|
||||
{
|
||||
$GLOBALS['__xmlparse_elapsed__'] += microtime(true) - $start;
|
||||
}
|
||||
$GLOBALS['__xmlparse_elapsed__'] += microtime(true) - $start;
|
||||
|
||||
return $output;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue