Beispiel #1
0
 /**
  * Add debugging information include queries and messages to output queue
  *
  * @param Util\Debug $debug
  */
 protected function addDebug(Util\Debug $debug)
 {
     echo '# level:' . CSV::DELIMITER . $debug->getLevel() . PHP_EOL;
     echo '# database:' . CSV::DELIMITER . Util\Configuration::read('db.driver') . PHP_EOL;
     echo '# time:' . CSV::DELIMITER . $debug->getExecutionTime() . PHP_EOL;
     if ($uptime = Util\Debug::getUptime()) {
         echo '# uptime:' . CSV::DELIMITER . $uptime * 1000;
     }
     if ($load = Util\Debug::getLoadAvg()) {
         echo '# load:' . CSV::DELIMITER . implode(', ', $load) . PHP_EOL;
     }
     if ($commit = Util\Debug::getCurrentCommit()) {
         echo '# commit-hash:' . CSV::DELIMITER . $commit;
     }
     if ($version = phpversion()) {
         echo '# php-version:' . CSV::DELIMITER . $version;
     }
     foreach ($debug->getMessages() as $message) {
         echo '# message:' . CSV::DELIMITER . $message['message'] . PHP_EOL;
         // TODO add more information
     }
     foreach ($debug->getQueries() as $query) {
         echo '# query:' . CSV::DELIMITER . $query['sql'] . PHP_EOL;
         if (isset($query['parameters'])) {
             echo "# \tparameters:" . CSV::DELIMITER . implode(', ', $query['parameters']) . PHP_EOL;
         }
     }
 }
Beispiel #2
0
 /**
  * Add debugging information include queries and messages to output queue
  *
  * @param Util\Debug $debug
  */
 protected function addDebug(Util\Debug $debug)
 {
     echo "level:\t" . $debug->getLevel() . PHP_EOL;
     echo "database:\t" . Util\Configuration::read('db.driver') . PHP_EOL;
     echo "time:\t" . $debug->getExecutionTime() . PHP_EOL;
     if ($uptime = Util\Debug::getUptime()) {
         echo "uptime:\t" . $uptime * 1000;
     }
     if ($load = Util\Debug::getLoadAvg()) {
         echo "load:\t" . implode(', ', $load) . PHP_EOL;
     }
     if ($commit = Util\Debug::getCurrentCommit()) {
         echo "commit-hash:\t" . $commit . PHP_EOL;
     }
     if ($version = phpversion()) {
         echo "php-version:\t" . $version . PHP_EOL;
     }
     foreach ($debug->getMessages() as $message) {
         echo "message:\t" . $message['message'] . PHP_EOL;
         // TODO add more information
     }
     foreach ($debug->getQueries() as $query) {
         echo "query:\t" . $query['sql'] . PHP_EOL;
         if (isset($query['parameters'])) {
             echo "\tparameters:\t" . implode(', ', $query['parameters']) . PHP_EOL;
         }
     }
 }
Beispiel #3
0
 /**
  * Add debugging information include queries and messages to output queue
  *
  * @param Util\Debug $debug
  */
 protected function convertDebug(Util\Debug $debug)
 {
     $jsonDebug['level'] = $debug->getLevel();
     if ($dbDriver = Util\Configuration::read('db.driver')) {
         $jsonDebug['database'] = $dbDriver;
     }
     $jsonDebug['time'] = $debug->getExecutionTime();
     if ($uptime = Util\Debug::getUptime()) {
         $jsonDebug['uptime'] = $uptime * 1000;
     }
     if ($load = Util\Debug::getLoadAvg()) {
         $jsonDebug['load'] = $load;
     }
     if ($commit = Util\Debug::getCurrentCommit()) {
         $jsonDebug['commit-hash'] = $commit;
     }
     if ($version = phpversion()) {
         $jsonDebug['php-version'] = $version;
     }
     $jsonDebug['messages'] = $debug->getMessages();
     // SQL statements
     if (count($statements = $debug->getQueries())) {
         $this->getSQLTimes($statements);
         $jsonDebug['sql'] = array('totalTime' => $this->sqlTotalTime, 'worstTime' => $this->sqlWorstTime, 'queries' => array_map(function ($q) {
             return array('sql' => Util\Debug::getParametrizedQuery($q['sql'], $q['params']), 'execTime' => $q['executionMS']);
         }, array_values($debug->getQueries())));
     }
     return $jsonDebug;
 }
Beispiel #4
0
 * A test for our JSON utility class
 *
 * @package tests
 * @copyright Copyright (c) 2011, The volkszaehler.org project
 * @license http://www.gnu.org/licenses/gpl.txt GNU Public License
 * @author Steffen Vogel <*****@*****.**>
 */
/*
 * This file is part of volkzaehler.org
 *
 * volkzaehler.org is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * any later version.
 *
 * volkzaehler.org is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with volkszaehler.org. If not, see <http://www.gnu.org/licenses/>.
 */
define('VZ_DIR', realpath(__DIR__ . '/../..'));
use Volkszaehler\Util;
include VZ_DIR . '/lib/Util/Debug.php';
echo '<pre>';
echo print_r(Util\Debug::getLoadAvg(), TRUE);
echo Util\Debug::getUptime() . "\n";
echo Util\Debug::getCurrentCommit();
echo '</pre>';
Beispiel #5
0
 /**
  * Add debugging information include queries and messages to output queue
  *
  * @param Util\Debug $debug
  */
 protected function addDebug(Util\Debug $debug)
 {
     $xmlDebug = $this->xmlDoc->createElement('debug');
     $xmlDebug->setAttribute('level', $debug->getLevel());
     $xmlDebug->appendChild($this->xmlDoc->createElement('time', $debug->getExecutionTime()));
     if ($uptime = Util\Debug::getUptime()) {
         $xmlDebug->appendChild($this->xmlDoc->createElement('uptime', $uptime * 1000));
     }
     if ($load = Util\Debug::getLoadAvg()) {
         $xmlDebug->appendChild($this->xmlDoc->createElement('load', implode(', ', $load)));
     }
     if ($commit = Util\Debug::getCurrentCommit()) {
         $xmlDebug->appendChild($this->xmlDoc->createElement('commit-hash', $commit));
     }
     if ($version = Util\Debug::getPhpVersion()) {
         $xmlDebug->appendChild($this->xmlDoc->createElement('php-version', $version));
     }
     $xmlMessages = $this->xmlDoc->createElement('messages');
     foreach ($debug->getMessages() as $message) {
         $xmlMessages->appendChild($this->convertMessage($message));
     }
     $xmlDebug->appendChild($xmlMessages);
     $xmlDebug->appendChild($this->convertArray($debug->getQueries(), 'queries', 'query'));
     $this->xmlRoot->appendChild($xmlDebug);
 }
Beispiel #6
0
 /**
  * Add debugging information include queries and messages to output queue
  *
  * @param Util\Debug $debug
  */
 protected function addDebug(Util\Debug $debug)
 {
     $jsonDebug['level'] = $debug->getLevel();
     if ($dbDriver = Util\Configuration::read('db.driver')) {
         $jsonDebug['database'] = $dbDriver;
     }
     $jsonDebug['time'] = $debug->getExecutionTime();
     if ($uptime = Util\Debug::getUptime()) {
         $jsonDebug['uptime'] = $uptime * 1000;
     }
     if ($load = Util\Debug::getLoadAvg()) {
         $jsonDebug['load'] = $load;
     }
     if ($commit = Util\Debug::getCurrentCommit()) {
         $jsonDebug['commit-hash'] = $commit;
     }
     if ($version = phpversion()) {
         $jsonDebug['php-version'] = $version;
     }
     $jsonDebug['messages'] = $debug->getMessages();
     // SQL statements
     $this->getSQLTimes($debug->getQueries());
     $jsonDebug['sql'] = array('totalTime' => $this->sqlTotalTime, 'worstTime' => $this->sqlWorstTime, 'queries' => array_values($debug->getQueries()));
     $this->json['debug'] = $jsonDebug;
 }