From e2bff0b35d7856ec23a4279b50261faebedd655f Mon Sep 17 00:00:00 2001 From: Roeland Jago Douma Date: Tue, 19 Apr 2016 19:29:47 +0200 Subject: Move \OC\Diagnostics to PSR-4 --- lib/private/Diagnostics/Event.php | 103 ++++++++++++++++++++++++++++ lib/private/Diagnostics/EventLogger.php | 55 +++++++++++++++ lib/private/Diagnostics/NullEventLogger.php | 57 +++++++++++++++ lib/private/Diagnostics/NullQueryLogger.php | 45 ++++++++++++ lib/private/Diagnostics/Query.php | 71 +++++++++++++++++++ lib/private/Diagnostics/QueryLogger.php | 61 ++++++++++++++++ lib/private/diagnostics/event.php | 103 ---------------------------- lib/private/diagnostics/eventlogger.php | 55 --------------- lib/private/diagnostics/nulleventlogger.php | 57 --------------- lib/private/diagnostics/nullquerylogger.php | 45 ------------ lib/private/diagnostics/query.php | 71 ------------------- lib/private/diagnostics/querylogger.php | 61 ---------------- 12 files changed, 392 insertions(+), 392 deletions(-) create mode 100644 lib/private/Diagnostics/Event.php create mode 100644 lib/private/Diagnostics/EventLogger.php create mode 100644 lib/private/Diagnostics/NullEventLogger.php create mode 100644 lib/private/Diagnostics/NullQueryLogger.php create mode 100644 lib/private/Diagnostics/Query.php create mode 100644 lib/private/Diagnostics/QueryLogger.php delete mode 100644 lib/private/diagnostics/event.php delete mode 100644 lib/private/diagnostics/eventlogger.php delete mode 100644 lib/private/diagnostics/nulleventlogger.php delete mode 100644 lib/private/diagnostics/nullquerylogger.php delete mode 100644 lib/private/diagnostics/query.php delete mode 100644 lib/private/diagnostics/querylogger.php diff --git a/lib/private/Diagnostics/Event.php b/lib/private/Diagnostics/Event.php new file mode 100644 index 00000000000..8b5bb7e3bd8 --- /dev/null +++ b/lib/private/Diagnostics/Event.php @@ -0,0 +1,103 @@ + + * @author Robin Appelman + * + * @copyright Copyright (c) 2016, ownCloud, Inc. + * @license AGPL-3.0 + * + * This code is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License, version 3, + * as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License, version 3, + * along with this program. If not, see + * + */ + +namespace OC\Diagnostics; + +use OCP\Diagnostics\IEvent; + +class Event implements IEvent { + /** + * @var string + */ + protected $id; + + /** + * @var float + */ + protected $start; + + /** + * @var float + */ + protected $end; + + /** + * @var string + */ + protected $description; + + /** + * @param string $id + * @param string $description + * @param float $start + */ + public function __construct($id, $description, $start) { + $this->id = $id; + $this->description = $description; + $this->start = $start; + } + + /** + * @param float $time + */ + public function end($time) { + $this->end = $time; + } + + /** + * @return float + */ + public function getStart() { + return $this->start; + } + + /** + * @return string + */ + public function getId() { + return $this->id; + } + + /** + * @return string + */ + public function getDescription() { + return $this->description; + } + + /** + * @return float + */ + public function getEnd() { + return $this->end; + } + + /** + * @return float + */ + public function getDuration() { + if (!$this->end) { + $this->end = microtime(true); + } + return $this->end - $this->start; + } +} diff --git a/lib/private/Diagnostics/EventLogger.php b/lib/private/Diagnostics/EventLogger.php new file mode 100644 index 00000000000..3d909ce79cd --- /dev/null +++ b/lib/private/Diagnostics/EventLogger.php @@ -0,0 +1,55 @@ + + * @author Robin Appelman + * + * @copyright Copyright (c) 2016, ownCloud, Inc. + * @license AGPL-3.0 + * + * This code is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License, version 3, + * as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License, version 3, + * along with this program. If not, see + * + */ + +namespace OC\Diagnostics; + +use OCP\Diagnostics\IEventLogger; + +class EventLogger implements IEventLogger { + /** + * @var \OC\Diagnostics\Event[] + */ + private $events = array(); + + public function start($id, $description) { + $this->events[$id] = new Event($id, $description, microtime(true)); + } + + public function end($id) { + if (isset($this->events[$id])) { + $timing = $this->events[$id]; + $timing->end(microtime(true)); + } + } + + public function log($id, $description, $start, $end) { + $this->events[$id] = new Event($id, $description, $start); + $this->events[$id]->end($end); + } + + /** + * @return \OCP\Diagnostics\IEvent[] + */ + public function getEvents() { + return $this->events; + } +} diff --git a/lib/private/Diagnostics/NullEventLogger.php b/lib/private/Diagnostics/NullEventLogger.php new file mode 100644 index 00000000000..1b5e7af3ac9 --- /dev/null +++ b/lib/private/Diagnostics/NullEventLogger.php @@ -0,0 +1,57 @@ + + * @author Robin Appelman + * + * @copyright Copyright (c) 2016, ownCloud, Inc. + * @license AGPL-3.0 + * + * This code is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License, version 3, + * as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License, version 3, + * along with this program. If not, see + * + */ + +namespace OC\Diagnostics; + +use OCP\Diagnostics\IEventLogger; + +/** + * Dummy event logger that doesn't actually log anything + */ +class NullEventLogger implements IEventLogger { + /** + * Mark the start of an event + * + * @param $id + * @param $description + */ + public function start($id, $description) { + } + + /** + * Mark the end of an event + * + * @param $id + */ + public function end($id) { + } + + public function log($id, $description, $start, $end) { + } + + /** + * @return \OCP\Diagnostics\IEvent[] + */ + public function getEvents() { + return array(); + } +} diff --git a/lib/private/Diagnostics/NullQueryLogger.php b/lib/private/Diagnostics/NullQueryLogger.php new file mode 100644 index 00000000000..98ddef2e783 --- /dev/null +++ b/lib/private/Diagnostics/NullQueryLogger.php @@ -0,0 +1,45 @@ + + * @author Robin Appelman + * + * @copyright Copyright (c) 2016, ownCloud, Inc. + * @license AGPL-3.0 + * + * This code is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License, version 3, + * as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License, version 3, + * along with this program. If not, see + * + */ + +namespace OC\Diagnostics; + +use OCP\Diagnostics\IQueryLogger; + +class NullQueryLogger 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\Diagnostics\IQuery[] + */ + public function getQueries() { + return array(); + } +} diff --git a/lib/private/Diagnostics/Query.php b/lib/private/Diagnostics/Query.php new file mode 100644 index 00000000000..567bc83ed4b --- /dev/null +++ b/lib/private/Diagnostics/Query.php @@ -0,0 +1,71 @@ + + * @author Robin Appelman + * + * @copyright Copyright (c) 2016, ownCloud, Inc. + * @license AGPL-3.0 + * + * This code is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License, version 3, + * as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License, version 3, + * along with this program. If not, see + * + */ + +namespace OC\Diagnostics; + +use OCP\Diagnostics\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; + } +} diff --git a/lib/private/Diagnostics/QueryLogger.php b/lib/private/Diagnostics/QueryLogger.php new file mode 100644 index 00000000000..66a65b71d04 --- /dev/null +++ b/lib/private/Diagnostics/QueryLogger.php @@ -0,0 +1,61 @@ + + * @author Robin Appelman + * + * @copyright Copyright (c) 2016, ownCloud, Inc. + * @license AGPL-3.0 + * + * This code is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License, version 3, + * as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License, version 3, + * along with this program. If not, see + * + */ + +namespace OC\Diagnostics; + +use OCP\Diagnostics\IQueryLogger; + +class QueryLogger implements IQueryLogger { + /** + * @var \OC\Diagnostics\Query + */ + protected $activeQuery; + + /** + * @var \OC\Diagnostics\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 Query[] + */ + public function getQueries() { + return $this->queries; + } +} diff --git a/lib/private/diagnostics/event.php b/lib/private/diagnostics/event.php deleted file mode 100644 index 8b5bb7e3bd8..00000000000 --- a/lib/private/diagnostics/event.php +++ /dev/null @@ -1,103 +0,0 @@ - - * @author Robin Appelman - * - * @copyright Copyright (c) 2016, ownCloud, Inc. - * @license AGPL-3.0 - * - * This code is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License, version 3, - * as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License, version 3, - * along with this program. If not, see - * - */ - -namespace OC\Diagnostics; - -use OCP\Diagnostics\IEvent; - -class Event implements IEvent { - /** - * @var string - */ - protected $id; - - /** - * @var float - */ - protected $start; - - /** - * @var float - */ - protected $end; - - /** - * @var string - */ - protected $description; - - /** - * @param string $id - * @param string $description - * @param float $start - */ - public function __construct($id, $description, $start) { - $this->id = $id; - $this->description = $description; - $this->start = $start; - } - - /** - * @param float $time - */ - public function end($time) { - $this->end = $time; - } - - /** - * @return float - */ - public function getStart() { - return $this->start; - } - - /** - * @return string - */ - public function getId() { - return $this->id; - } - - /** - * @return string - */ - public function getDescription() { - return $this->description; - } - - /** - * @return float - */ - public function getEnd() { - return $this->end; - } - - /** - * @return float - */ - public function getDuration() { - if (!$this->end) { - $this->end = microtime(true); - } - return $this->end - $this->start; - } -} diff --git a/lib/private/diagnostics/eventlogger.php b/lib/private/diagnostics/eventlogger.php deleted file mode 100644 index 3d909ce79cd..00000000000 --- a/lib/private/diagnostics/eventlogger.php +++ /dev/null @@ -1,55 +0,0 @@ - - * @author Robin Appelman - * - * @copyright Copyright (c) 2016, ownCloud, Inc. - * @license AGPL-3.0 - * - * This code is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License, version 3, - * as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License, version 3, - * along with this program. If not, see - * - */ - -namespace OC\Diagnostics; - -use OCP\Diagnostics\IEventLogger; - -class EventLogger implements IEventLogger { - /** - * @var \OC\Diagnostics\Event[] - */ - private $events = array(); - - public function start($id, $description) { - $this->events[$id] = new Event($id, $description, microtime(true)); - } - - public function end($id) { - if (isset($this->events[$id])) { - $timing = $this->events[$id]; - $timing->end(microtime(true)); - } - } - - public function log($id, $description, $start, $end) { - $this->events[$id] = new Event($id, $description, $start); - $this->events[$id]->end($end); - } - - /** - * @return \OCP\Diagnostics\IEvent[] - */ - public function getEvents() { - return $this->events; - } -} diff --git a/lib/private/diagnostics/nulleventlogger.php b/lib/private/diagnostics/nulleventlogger.php deleted file mode 100644 index 1b5e7af3ac9..00000000000 --- a/lib/private/diagnostics/nulleventlogger.php +++ /dev/null @@ -1,57 +0,0 @@ - - * @author Robin Appelman - * - * @copyright Copyright (c) 2016, ownCloud, Inc. - * @license AGPL-3.0 - * - * This code is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License, version 3, - * as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License, version 3, - * along with this program. If not, see - * - */ - -namespace OC\Diagnostics; - -use OCP\Diagnostics\IEventLogger; - -/** - * Dummy event logger that doesn't actually log anything - */ -class NullEventLogger implements IEventLogger { - /** - * Mark the start of an event - * - * @param $id - * @param $description - */ - public function start($id, $description) { - } - - /** - * Mark the end of an event - * - * @param $id - */ - public function end($id) { - } - - public function log($id, $description, $start, $end) { - } - - /** - * @return \OCP\Diagnostics\IEvent[] - */ - public function getEvents() { - return array(); - } -} diff --git a/lib/private/diagnostics/nullquerylogger.php b/lib/private/diagnostics/nullquerylogger.php deleted file mode 100644 index 98ddef2e783..00000000000 --- a/lib/private/diagnostics/nullquerylogger.php +++ /dev/null @@ -1,45 +0,0 @@ - - * @author Robin Appelman - * - * @copyright Copyright (c) 2016, ownCloud, Inc. - * @license AGPL-3.0 - * - * This code is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License, version 3, - * as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License, version 3, - * along with this program. If not, see - * - */ - -namespace OC\Diagnostics; - -use OCP\Diagnostics\IQueryLogger; - -class NullQueryLogger 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\Diagnostics\IQuery[] - */ - public function getQueries() { - return array(); - } -} diff --git a/lib/private/diagnostics/query.php b/lib/private/diagnostics/query.php deleted file mode 100644 index 567bc83ed4b..00000000000 --- a/lib/private/diagnostics/query.php +++ /dev/null @@ -1,71 +0,0 @@ - - * @author Robin Appelman - * - * @copyright Copyright (c) 2016, ownCloud, Inc. - * @license AGPL-3.0 - * - * This code is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License, version 3, - * as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License, version 3, - * along with this program. If not, see - * - */ - -namespace OC\Diagnostics; - -use OCP\Diagnostics\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; - } -} diff --git a/lib/private/diagnostics/querylogger.php b/lib/private/diagnostics/querylogger.php deleted file mode 100644 index 66a65b71d04..00000000000 --- a/lib/private/diagnostics/querylogger.php +++ /dev/null @@ -1,61 +0,0 @@ - - * @author Robin Appelman - * - * @copyright Copyright (c) 2016, ownCloud, Inc. - * @license AGPL-3.0 - * - * This code is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License, version 3, - * as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License, version 3, - * along with this program. If not, see - * - */ - -namespace OC\Diagnostics; - -use OCP\Diagnostics\IQueryLogger; - -class QueryLogger implements IQueryLogger { - /** - * @var \OC\Diagnostics\Query - */ - protected $activeQuery; - - /** - * @var \OC\Diagnostics\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 Query[] - */ - public function getQueries() { - return $this->queries; - } -} -- cgit v1.2.3