Ejemplo n.º 1
0
 static function getInstance()
 {
     if (empty(self::$_instance)) {
         self::$_instance = new self();
     }
     return self::$_instance;
 }
Ejemplo n.º 2
0
 static function logPHP($area, $thing)
 {
     if (!defined('SHOWDEBUG')) {
         return;
     }
     $log = Plank_Logger_Output::getInstance();
     $log->logPHP($area, $thing);
 }
Ejemplo n.º 3
0
    function display()
    {
        if (!defined('SHOWDEBUG') || !SHOWDEBUG) {
            return;
        }
        $out = <<<EOW
\t\t
\t<!-- begin Plank Inline Debuggery -->
\t<script type="text/javascript">
\t
\t\tfunction plankShowDebug(what){
\t\t\tdocument.getElementById('plankDebugLogs').style.display = 'none';
\t\t\tdocument.getElementById('plankDebugQueries').style.display = 'none';
\t\t\tdocument.getElementById('plankDebugStats').style.display = 'none';
\t\t\t
\t\t\tdocument.getElementById(what).style.display = 'block';
\t\t\t
\t\t}
\t\t
\t\tfunction plankHideDebug(){
\t\t\tdocument.getElementById('plankDebugPane').style.display = 'none';
\t\t}
\t
\t</script>
\t<style type="text/css">
\t\t#plankDebugPane {
\t\t\topacity: .25;
\t\t\tfilter: alpha(opacity=25);
\t\t\t-ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=25)";


\t\t\tborder: 1px solid red;\t
\t\t\tposition: absolute;
\t\t\ttop: 0;
\t\t\tright: 0;
\t\t\tz-index: 10000;
\t\t\tbackground: #FFF;
\t\t\tfont-family: "Trebuchet MS" sans-serif;
\t\t\tborder: 1px solid #840000;\t
\t\t\t-moz-border-radius: 15px 0 15px 30px;
\t\t\t-webkit-border-radius: 30px 60px 30px 60px;
\t\t\t

\t\t\t
\t\t\tpadding-left: .5em;
\t\t}
\t\t
\t\t#plankDebugPane:hover {

\t\t\topacity: .85;
\t\t\tfilter: alpha(opacity=85);
\t\t\t-ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=85)";
\t\t}
\t
\t\t#plankDebugPane div.logView {
\t\t\tpadding-bottom: 1em;
\t\t\toverflow: auto;
\t\t\tmax-width: 100%;
\t\t\twidth: 1024px;
\t\t}
\t\t
\t\t.plankLogo {
\t\t\tcolor: #840000;
\t\t\tfont-size: larger;\t
\t\t}
\t</style>
\t
EOW;
        $logOutput = Plank_Logger_Output::getInstance();
        list($log, $queries, $stats) = $logOutput->giveMeLogs();
        echo '
	<div id="plankDebugPane">
		<div class="plankDebugNav"><span class="plankLogo">Plank</span>: Show [ 
		<a href="javascript:plankShowDebug(\'plankDebugLogs\')">' . count($log) . ' Logs</a> | 
		<a href="javascript:plankShowDebug(\'plankDebugQueries\')">Queries</a> | 
		<a href="javascript:plankShowDebug(\'plankDebugStats\')">' . count($stats) . ' Timings</a> | 
		<a href="javascript:plankShowDebug(\'plankDebugPane\')">Nothing</a> |
		<a href="javascript:plankHideDebug()">X</a>]</div> 
	';
        $strf = "<tt>[%2.5f][%d][%s]</tt> %s<br />";
        $out .= '<div id="plankDebugLogs" class="logView" style="display: none"><h2>Logs</h2>';
        foreach ($log as $logline) {
            if (is_array($logline[2])) {
                foreach ($logline[2] as $index => $item) {
                    $out .= sprintf($strf, $logline[0] - T, $logline[3], $logline[1], "<tt>[{$index}]</tt>" . $item);
                }
            } else {
                $out .= sprintf($strf, $logline[0] - T, $logline[3], $logline[1], htmlentities($logline[2]));
            }
        }
        $out .= "\n</div>";
        $out .= '<div id="plankDebugQueries" class="logView" style="display: none"><h2>Queries</h2>';
        if (Plank_DB::hasInstance()) {
            $db = Plank_DB::getInstance();
            foreach ($db->listConnections() as $connection) {
                $out .= $db->connection($connection)->getDebugOutput();
            }
        } else {
            $out .= 'No Queries';
        }
        $out .= "\n</div>";
        $out .= '<div id="plankDebugStats" class="logView" style="display: none"><h2>Stats</h2>';
        foreach ($stats as $logline) {
            $message = $logline[2];
            if (is_array($message)) {
                foreach ($message as $index => $item) {
                    $out .= sprintf('[%2.5f][%s] %s<br/>', $logline[0] - T, $logline[1], $index . " - " . $item);
                }
            } else {
                $out .= sprintf('[%2.5f][%s] %s<br/>', $logline[0] - T, $logline[1], $logline[2]);
            }
        }
        $out .= sprintf('( %2.5f total)', microtime(true) - T);
        $out .= "\n</div>";
        $out .= '	</div>';
        return $out;
    }