aboutsummaryrefslogtreecommitdiffstats
path: root/lib/private/Diagnostics/QueryLogger.php
diff options
context:
space:
mode:
Diffstat (limited to 'lib/private/Diagnostics/QueryLogger.php')
-rw-r--r--lib/private/Diagnostics/QueryLogger.php33
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;
+ }
}