diff options
author | Piotr Mrówczyński <mrow4a@yahoo.com> | 2017-04-20 11:31:00 +0200 |
---|---|---|
committer | Joas Schilling <coding@schilljs.com> | 2017-04-26 13:19:43 +0200 |
commit | 9fec4031b30f5ab56af2f8c284672fcd444e8b62 (patch) | |
tree | bbecebfaa1fa8fd376b02dec9078573478fd6864 /lib/private/Diagnostics/QueryLogger.php | |
parent | 5b5c3a1773dab4960d41aafc4150859a308311b7 (diff) | |
download | nextcloud-server-9fec4031b30f5ab56af2f8c284672fcd444e8b62.tar.gz nextcloud-server-9fec4031b30f5ab56af2f8c284672fcd444e8b62.zip |
Adjust query/event logging code in favour of more complex owncloud/diagnostics (#27643)
* Adjust query/event logging code in favour of more complex owncloud/diagnostics
* Add descriptions to IQueryLogger and IEventLogger interfaces
Diffstat (limited to 'lib/private/Diagnostics/QueryLogger.php')
-rw-r--r-- | lib/private/Diagnostics/QueryLogger.php | 33 |
1 files changed, 27 insertions, 6 deletions
diff --git a/lib/private/Diagnostics/QueryLogger.php b/lib/private/Diagnostics/QueryLogger.php index 5f2a061a910..54ce3542f49 100644 --- a/lib/private/Diagnostics/QueryLogger.php +++ b/lib/private/Diagnostics/QueryLogger.php @@ -3,7 +3,13 @@ * @copyright Copyright (c) 2016, ownCloud, Inc. * * @author Morris Jobke <hey@morrisjobke.de> +<<<<<<< HEAD * @author Robin Appelman <robin@icewind.nl> +======= + * @author Robin Appelman <icewind@owncloud.com> + * @author Thomas Müller <thomas.mueller@tmit.eu> + * @author Piotr Mrowczynski <piotr@owncloud.com> +>>>>>>> a5095447b7... Adjust query/event logging code in favour of more complex owncloud/diagnostics (#27643) * * @license AGPL-3.0 * @@ -46,12 +52,17 @@ class QueryLogger implements IQueryLogger { /** - * @param string $sql - * @param array $params - * @param array $types + * @var bool - Module needs to be activated by some app + */ + private $activated = false; + + /** + * @inheritdoc */ public function startQuery($sql, array $params = null, array $types = null) { - $this->activeQuery = new Query($sql, $params, microtime(true), $this->getStack()); + if ($this->activated) { + $this->activeQuery = new Query($sql, $params, microtime(true), $this->getStack()); + } } private function getStack() { @@ -62,8 +73,11 @@ class QueryLogger implements IQueryLogger { return $stack; } + /** + * @inheritdoc + */ public function stopQuery() { - if ($this->activeQuery) { + if ($this->activated && $this->activeQuery) { $this->activeQuery->end(microtime(true)); $this->queries[] = $this->activeQuery; $this->activeQuery = null; @@ -71,9 +85,16 @@ class QueryLogger implements IQueryLogger { } /** - * @return Query[] + * @inheritdoc */ public function getQueries() { return $this->queries->getData(); } + + /** + * @inheritdoc + */ + public function activate() { + $this->activated = true; + } } |