Example #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;
         }
     }
 }
Example #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;
         }
     }
 }
Example #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;
 }
Example #4
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);
 }
Example #5
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;
 }