moved statistics and library versions from capabilities to debugging section
This commit is contained in:
parent
c288426657
commit
50794fd47e
5 changed files with 38 additions and 49 deletions
|
@ -54,17 +54,6 @@ class CapabilitiesController extends Controller {
|
|||
$capabilities['configuration'] = $configuration;
|
||||
}
|
||||
|
||||
if (is_null($section) || $section == 'statistics') { // TODO database statistics
|
||||
$statistics = array();
|
||||
|
||||
if ($load = Util\Debug::getLoadAvg()) $statistics['load'] = $load;
|
||||
if ($uptime = Util\Debug::getUptime()) $statistics['uptime'] = $uptime*1000;
|
||||
if ($commit = Util\Debug::getCurrentCommit()) $statistics['commit-hash'] = $commit;
|
||||
if ($version = phpversion()) $statistics['php-version'] = $version;
|
||||
|
||||
$capabilities['statistics'] = $statistics;
|
||||
}
|
||||
|
||||
if (is_null($section) || $section == 'formats') {
|
||||
$capabilities['formats'] = array_keys(\Volkszaehler\Router::$viewMapping);
|
||||
}
|
||||
|
|
|
@ -147,6 +147,10 @@ class Debug {
|
|||
}
|
||||
}
|
||||
|
||||
public static function getPhpVersion() {
|
||||
return phpversion();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get average server load
|
||||
*
|
||||
|
|
|
@ -78,8 +78,14 @@ class CSV extends View {
|
|||
* @param Util\Debug $debug
|
||||
*/
|
||||
protected function addDebug(Util\Debug $debug) {
|
||||
echo '# time: ' . $debug->getExecutionTime() . PHP_EOL;
|
||||
echo '# level: ' . $debug->getLevel() . PHP_EOL;
|
||||
echo '# database: ' . Util\Configuration::read('db.driver') . PHP_EOL;
|
||||
echo '# time: ' . $debug->getExecutionTime() . PHP_EOL;
|
||||
|
||||
if ($uptime = Util\Debug::getUptime()) echo '# uptime: ' . $uptime*1000;
|
||||
if ($load = Util\Debug::getLoadAvg()) echo '# load: ' . implode(', ', $load) . PHP_EOL;
|
||||
if ($commit = Util\Debug::getCurrentCommit()) echo '# commit-hash: ' . $commit;
|
||||
if ($version = Util\Debug::getPhpVersion()) echo '# php-version: ' . $version;
|
||||
|
||||
foreach ($debug->getMessages() as $message) {
|
||||
echo '# message: ' . $message['message'] . PHP_EOL; // TODO add more information
|
||||
|
@ -141,23 +147,12 @@ class CSV extends View {
|
|||
|
||||
echo '# uuid: ' . $interpreter->getEntity()->getUuid() . PHP_EOL;
|
||||
|
||||
if (isset($from))
|
||||
echo '# from: ' . $from . PHP_EOL;
|
||||
|
||||
if (isset($to))
|
||||
echo '# to: ' . $to . PHP_EOL;
|
||||
|
||||
if (isset($min))
|
||||
echo '# min: ' . $min[0] . ' => ' . $min[1] . PHP_EOL;
|
||||
|
||||
if (isset($max))
|
||||
echo '# max: ' . $max[0] . ' => ' . $max[1] . PHP_EOL;
|
||||
|
||||
if (isset($average))
|
||||
echo '# average: ' . View::formatNumber($average) . PHP_EOL;
|
||||
|
||||
if (isset($consumption))
|
||||
echo '# consumption: ' . View::formatNumber($consumption) . PHP_EOL;
|
||||
if (isset($from)) echo '# from: ' . $from . PHP_EOL;
|
||||
if (isset($to)) echo '# to: ' . $to . PHP_EOL;
|
||||
if (isset($min)) echo '# min: ' . $min[0] . ' => ' . $min[1] . PHP_EOL;
|
||||
if (isset($max)) echo '# max: ' . $max[0] . ' => ' . $max[1] . PHP_EOL;
|
||||
if (isset($average)) echo '# average: ' . View::formatNumber($average) . PHP_EOL;
|
||||
if (isset($consumption)) echo '# consumption: ' . View::formatNumber($consumption) . PHP_EOL;
|
||||
|
||||
echo '# rows: ' . $interpreter->getRowCount() . PHP_EOL;
|
||||
|
||||
|
|
|
@ -129,8 +129,15 @@ class JSON extends View {
|
|||
* @param Util\Debug $debug
|
||||
*/
|
||||
protected function addDebug(Util\Debug $debug) {
|
||||
$jsonDebug['time'] = $debug->getExecutionTime();
|
||||
$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 = Util\Debug::getPhpVersion()) $jsonDebug['php-version'] = $version;
|
||||
|
||||
$jsonDebug['messages'] = $debug->getMessages();
|
||||
$jsonDebug['queries'] = array_values($debug->getQueries());
|
||||
|
||||
|
@ -189,26 +196,15 @@ class JSON extends View {
|
|||
$from = $interpreter->getFrom();
|
||||
$to = $interpreter->getTo();
|
||||
|
||||
$this->json['data']['uuid'] = $interpreter->getEntity()->getUuid();
|
||||
if (isset($from))
|
||||
$this->json['data']['from'] = $from;
|
||||
$this->json['data']['uuid'] = $interpreter->getEntity()->getUuid();
|
||||
if (isset($from)) $this->json['data']['from'] = $from;
|
||||
if (isset($to)) $this->json['data']['to'] = $to;
|
||||
if (isset($min)) $this->json['data']['min'] = $min;
|
||||
if (isset($max)) $this->json['data']['max'] = $max;
|
||||
if (isset($average)) $this->json['data']['average'] = View::formatNumber($average);
|
||||
if (isset($consumption)) $this->json['data']['consumption'] = View::formatNumber($consumption);
|
||||
|
||||
if (isset($to))
|
||||
$this->json['data']['to'] = $to;
|
||||
|
||||
if (isset($min))
|
||||
$this->json['data']['min'] = $min;
|
||||
|
||||
if (isset($max))
|
||||
$this->json['data']['max'] = $max;
|
||||
|
||||
if (isset($average))
|
||||
$this->json['data']['average'] = View::formatNumber($average);
|
||||
|
||||
if (isset($consumption))
|
||||
$this->json['data']['consumption'] = View::formatNumber($consumption);
|
||||
|
||||
$this->json['data']['rows'] = $interpreter->getRowCount();
|
||||
$this->json['data']['rows'] = $interpreter->getRowCount();
|
||||
|
||||
if (($interpreter->getTupleCount() > 0 || is_null($interpreter->getTupleCount())) && count($data) > 0)
|
||||
$this->json['data']['tuples'] = $data;
|
||||
|
|
|
@ -166,6 +166,11 @@ class XML extends View {
|
|||
$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) {
|
||||
|
|
Loading…
Add table
Reference in a new issue