parent
d38050cf52
commit
b71d1d3616
@ -0,0 +1,31 @@ |
||||
<?php |
||||
/** |
||||
* Copyright (c) 2014 Robin Appelman <icewind@owncloud.com> |
||||
* This file is licensed under the Affero General Public License version 3 or |
||||
* later. |
||||
* See the COPYING-README file. |
||||
*/ |
||||
|
||||
namespace OC\Debug; |
||||
|
||||
use OCP\Debug\IQueryLogger; |
||||
|
||||
class DummyQueryLogger implements IQueryLogger { |
||||
/** |
||||
* @param string $sql |
||||
* @param array $params |
||||
* @param array $types |
||||
*/ |
||||
public function startQuery($sql, array $params = null, array $types = null) { |
||||
} |
||||
|
||||
public function stopQuery() { |
||||
} |
||||
|
||||
/** |
||||
* @return \OCP\Debug\IQuery[] |
||||
*/ |
||||
public function getQueries() { |
||||
return array(); |
||||
} |
||||
} |
||||
@ -0,0 +1,57 @@ |
||||
<?php |
||||
/** |
||||
* Copyright (c) 2014 Robin Appelman <icewind@owncloud.com> |
||||
* This file is licensed under the Affero General Public License version 3 or |
||||
* later. |
||||
* See the COPYING-README file. |
||||
*/ |
||||
|
||||
namespace OC\Debug; |
||||
|
||||
use OCP\Debug\IQuery; |
||||
|
||||
class Query implements IQuery { |
||||
private $sql; |
||||
|
||||
private $params; |
||||
|
||||
private $start; |
||||
|
||||
private $end; |
||||
|
||||
/** |
||||
* @param string $sql |
||||
* @param array $params |
||||
* @param int $start |
||||
*/ |
||||
public function __construct($sql, $params, $start) { |
||||
$this->sql = $sql; |
||||
$this->params = $params; |
||||
$this->start = $start; |
||||
} |
||||
|
||||
public function end($time) { |
||||
$this->end = $time; |
||||
} |
||||
|
||||
/** |
||||
* @return array |
||||
*/ |
||||
public function getParams() { |
||||
return $this->params; |
||||
} |
||||
|
||||
/** |
||||
* @return string |
||||
*/ |
||||
public function getSql() { |
||||
return $this->sql; |
||||
} |
||||
|
||||
/** |
||||
* @return int |
||||
*/ |
||||
public function getDuration() { |
||||
return $this->end - $this->start; |
||||
} |
||||
} |
||||
@ -0,0 +1,47 @@ |
||||
<?php |
||||
/** |
||||
* Copyright (c) 2014 Robin Appelman <icewind@owncloud.com> |
||||
* This file is licensed under the Affero General Public License version 3 or |
||||
* later. |
||||
* See the COPYING-README file. |
||||
*/ |
||||
|
||||
namespace OC\Debug; |
||||
|
||||
use OCP\Debug\IQueryLogger; |
||||
|
||||
class QueryLogger implements IQueryLogger { |
||||
/** |
||||
* @var \OC\Debug\Query |
||||
*/ |
||||
protected $activeQuery; |
||||
|
||||
/** |
||||
* @var \OC\Debug\Query[] |
||||
*/ |
||||
protected $queries = array(); |
||||
|
||||
/** |
||||
* @param string $sql |
||||
* @param array $params |
||||
* @param array $types |
||||
*/ |
||||
public function startQuery($sql, array $params = null, array $types = null) { |
||||
$this->activeQuery = new Query($sql, $params, microtime(true)); |
||||
} |
||||
|
||||
public function stopQuery() { |
||||
if ($this->activeQuery) { |
||||
$this->activeQuery->end(microtime(true)); |
||||
$this->queries[] = $this->activeQuery; |
||||
$this->activeQuery = null; |
||||
} |
||||
} |
||||
|
||||
/** |
||||
* @return \OCP\Debug\IQuery[] |
||||
*/ |
||||
public function getQueries() { |
||||
return $this->queries; |
||||
} |
||||
} |
||||
@ -0,0 +1,26 @@ |
||||
<?php |
||||
/** |
||||
* Copyright (c) 2014 Robin Appelman <icewind@owncloud.com> |
||||
* This file is licensed under the Affero General Public License version 3 or |
||||
* later. |
||||
* See the COPYING-README file. |
||||
*/ |
||||
|
||||
namespace OCP\Debug; |
||||
|
||||
interface IQuery { |
||||
/** |
||||
* @return string |
||||
*/ |
||||
public function getSql(); |
||||
|
||||
/** |
||||
* @return array |
||||
*/ |
||||
public function getParams(); |
||||
|
||||
/** |
||||
* @return float |
||||
*/ |
||||
public function getDuration(); |
||||
} |
||||
@ -0,0 +1,27 @@ |
||||
<?php |
||||
/** |
||||
* Copyright (c) 2014 Robin Appelman <icewind@owncloud.com> |
||||
* This file is licensed under the Affero General Public License version 3 or |
||||
* later. |
||||
* See the COPYING-README file. |
||||
*/ |
||||
|
||||
namespace OCP\Debug; |
||||
|
||||
use Doctrine\DBAL\Logging\SQLLogger; |
||||
|
||||
interface IQueryLogger extends SQLLogger { |
||||
/** |
||||
* @param string $sql |
||||
* @param array $params |
||||
* @param array $types |
||||
*/ |
||||
public function startQuery($sql, array $params = null, array $types = null); |
||||
|
||||
public function stopQuery(); |
||||
|
||||
/** |
||||
* @return \OCP\Debug\IQuery[] |
||||
*/ |
||||
public function getQueries(); |
||||
} |
||||
Loading…
Reference in new issue