forked from bcit-ci/CodeIgniter
-
Notifications
You must be signed in to change notification settings - Fork 26
Custom profiler overdiv
Derek Jones edited this page Jul 5, 2012
·
11 revisions
Custom profiler, similar in function to Kohana profiler, overdiv on top and hidden, activated by mouse click.
Uses jQuery.
Hope can be a base to make a better visual profiler.
Download: File:MY_Profiler.zip
Install:
Copy the file to your application/libraries directory Be sure your subclass_prefix config (in config.php), its MY_, else change the MY_Profiler.php name to your subclass_prefix name, also remember to modify class name in the MY_Profiler.php file.
<?php if (!defined('BASEPATH')) exit('No direct script access allowed');
class MY_Profiler extends CI_Profiler
{
function MY_profiler()
{
parent::CI_Profiler();
}
function run()
{
// START JQueryLoad
// Remove if you load Jquery else where
$output = '<script type="text/javascript" src="http://code.jquery.com/jquery.min.js"></script>';
// End JQueryLoad
$i_currentDIV = rand(10,99).substr(md5($_SERVER["REQUEST_URI"]),0,6);
$output .= "<div id='debugTrace".$i_currentDIV."X' style='position:absolute;top:0px;left:0px;width:20px;height:30px;border:#FFFFEB solid 2px;filter:progid:DXImageTransform.Microsoft.gradient(startColorstr=#80000000,endColorstr=#10000000);background: rgba(135, 135, 135, 0.6);color:red;z-index:9999;'>";
$output .= "<a href='[removed];'> <font color='red' size='5'>X</font> </a>";
$output .= "</div>";
$output .= "<div id='debugTrace".$i_currentDIV."' style='position:absolute;top:0px;left:20px;width:100%;border:#FFFFEB solid 2px;filter:progid:DXImageTransform.Microsoft.gradient(startColorstr=#80000000,endColorstr=#10000000);background: rgba(135, 135, 135, 0.6);color:red;z-index:9999;'>";
$output .= "<table align='center' border='0' width='98%'>";
$output .= "<tr>";
$output .= "<td align='left' width='10%'><a href='[removed];'> URI </a></td>";
$output .= "<td align='left' width='10%'><a href='[removed];'> Controler </a></td>";
$output .= "<td align='left' width='10%'><a href='[removed];'> Memory </a></td>";
$output .= "<td align='left' width='10%'><a href='[removed];'> Benchmarks </a></td>";
$output .= "<td align='left' width='10%'><a href='[removed];'> Variables </a></td>";
$output .= "<td align='left' width='10%'><a href='[removed];'> SQL </a></td>";
$output .= "<td align='right' width='80%'><a href='[removed];'> <strong><<<</strong> </a></td>";
$output .= "</tr>";
$output .= "<tr>";
$output .= "<td colspan='99'>";
$output .= "<div id='codeigniter_profiler_URI' class='codeigniter_profiler' style='position:relative;top:0px;padding:10px;width:90%;text-align:left;background-color:#fff;border:1px solid silver;z-index:9999;display:none;color:silver;'>";
$output .= $this->_compile_uri_string();
$output .= "</div>";
$output .= "<div id='codeigniter_profiler_CTRL' class='codeigniter_profiler' style='position:relative;top:0px;padding:10px;width:90%;text-align:left;background-color:#fff;border:1px solid silver;z-index:9999;display:none;color:silver;'>";
$output .= $this->_compile_controller_info();
$output .= "</div>";
$output .= "<div id='codeigniter_profiler_MEM' class='codeigniter_profiler' style='position:relative;top:0px;padding:10px;width:90%;text-align:left;background-color:#fff;border:1px solid silver;z-index:9999;display:none;color:silver;'>";
$output .= $this->_compile_memory_usage();
$output .= "</div>";
$output .= "<div id='codeigniter_profiler_BENCH' class='codeigniter_profiler' style='position:relative;top:0px;padding:10px;width:90%;text-align:left;background-color:#fff;border:1px solid silver;z-index:9999;display:none;color:silver;'>";
$output .= $this->_compile_benchmarks();
$output .= "</div>";
$output .= "<div id='codeigniter_profiler_VARS' class='codeigniter_profiler' style='position:relative;top:0px;padding:10px;width:90%;text-align:left;background-color:#fff;border:1px solid silver;z-index:9999;display:none;color:silver;'>";
$output .= $this->_compile_get();
$output .= $this->_compile_post();
$output .= "</div>";
$output .= "<div id='codeigniter_profiler_SQL' class='codeigniter_profiler' style='position:relative;top:0px;padding:10px;width:90%;text-align:left;background-color:#fff;border:1px solid silver;z-index:9999;display:none;color:silver;'>";
$output .= $this->_compile_queries();
$output .= "</div>";
$output .= "</td>";
$output .= "</tr>";
$output .= "</table>";
$output .= "</div>";
return $output;
}
}