diff options
author | Morris Jobke <hey@morrisjobke.de> | 2017-04-26 22:58:01 -0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-04-26 22:58:01 -0300 |
commit | 01705b1b6a500199796c1d289ae8dd7363c27383 (patch) | |
tree | e647526349c54a1d008691b2af0ed95112816220 /lib/private/Diagnostics/EventLogger.php | |
parent | 0ac806a9dd69eee2ef80bb4d256d3a1355dd36f3 (diff) | |
parent | d0bbae7425e8a39788222dcaab17466c24c3c089 (diff) | |
download | nextcloud-server-01705b1b6a500199796c1d289ae8dd7363c27383.tar.gz nextcloud-server-01705b1b6a500199796c1d289ae8dd7363c27383.zip |
Merge pull request #4515 from nextcloud/downstream-27643
Adjust query/event logging code in favour of more complex owncloud/di…
Diffstat (limited to 'lib/private/Diagnostics/EventLogger.php')
-rw-r--r-- | lib/private/Diagnostics/EventLogger.php | 39 |
1 files changed, 33 insertions, 6 deletions
diff --git a/lib/private/Diagnostics/EventLogger.php b/lib/private/Diagnostics/EventLogger.php index 5abaae3f1dd..846be7efc5b 100644 --- a/lib/private/Diagnostics/EventLogger.php +++ b/lib/private/Diagnostics/EventLogger.php @@ -4,6 +4,8 @@ * * @author Morris Jobke <hey@morrisjobke.de> * @author Robin Appelman <robin@icewind.nl> + * @author Thomas Müller <thomas.mueller@tmit.eu> + * @author Piotr Mrowczynski <piotr@owncloud.com> * * @license AGPL-3.0 * @@ -29,28 +31,53 @@ class EventLogger implements IEventLogger { /** * @var \OC\Diagnostics\Event[] */ - private $events = array(); + private $events = []; + + /** + * @var bool - Module needs to be activated by some app + */ + private $activated = false; + /** + * @inheritdoc + */ public function start($id, $description) { - $this->events[$id] = new Event($id, $description, microtime(true)); + if ($this->activated){ + $this->events[$id] = new Event($id, $description, microtime(true)); + } } + /** + * @inheritdoc + */ public function end($id) { - if (isset($this->events[$id])) { + if ($this->activated && isset($this->events[$id])) { $timing = $this->events[$id]; $timing->end(microtime(true)); } } + /** + * @inheritdoc + */ public function log($id, $description, $start, $end) { - $this->events[$id] = new Event($id, $description, $start); - $this->events[$id]->end($end); + if ($this->activated) { + $this->events[$id] = new Event($id, $description, $start); + $this->events[$id]->end($end); + } } /** - * @return \OCP\Diagnostics\IEvent[] + * @inheritdoc */ public function getEvents() { return $this->events; } + + /** + * @inheritdoc + */ + public function activate() { + $this->activated = true; + } } |