From: Gunnar Wrobel Date: Thu, 30 Dec 2010 10:48:44 +0000 (+0100) Subject: Fix logging. X-Git-Url: https://git.internetallee.de/?a=commitdiff_plain;h=5e44ec49f4170bc3316f70b5d617e2c57eb2ad50;p=horde.git Fix logging. --- diff --git a/framework/Kolab_Storage/lib/Horde/Kolab/Storage/Driver/Decorator/Log.php b/framework/Kolab_Storage/lib/Horde/Kolab/Storage/Driver/Decorator/Log.php index 1e6910cd0..896731c37 100644 --- a/framework/Kolab_Storage/lib/Horde/Kolab/Storage/Driver/Decorator/Log.php +++ b/framework/Kolab_Storage/lib/Horde/Kolab/Storage/Driver/Decorator/Log.php @@ -69,6 +69,29 @@ extends Horde_Kolab_Storage_Driver_Decorator_Base } /** + * Retrieves the specified annotation for the complete list of mailboxes. + * + * @param string $annotation The name of the annotation to retrieve. + * + * @return array An associative array combining the folder names as key with + * the corresponding annotation value. + */ + public function listAnnotation($annotation) + { + $this->_logger->info( + sprintf('Driver "%s": Listing annotation "%s".', $this->getDriverName(), $annotation) + ); + $result = parent::listAnnotation($annotation); + $this->_logger->info( + sprintf( + 'Driver "%s": List contained %s folder annotations.', + $this->getDriverName(), + count($result)) + ); + return $result; + } + + /** * Does the given folder exist? * * @param string $folder The folder to check. diff --git a/framework/Kolab_Storage/lib/Horde/Kolab/Storage/Driver/Decorator/Timer.php b/framework/Kolab_Storage/lib/Horde/Kolab/Storage/Driver/Decorator/Timer.php index 436209879..fed29665a 100644 --- a/framework/Kolab_Storage/lib/Horde/Kolab/Storage/Driver/Decorator/Timer.php +++ b/framework/Kolab_Storage/lib/Horde/Kolab/Storage/Driver/Decorator/Timer.php @@ -79,6 +79,27 @@ extends Horde_Kolab_Storage_Driver_Decorator_Base } /** + * Retrieves the specified annotation for the complete list of mailboxes. + * + * @param string $annotation The name of the annotation to retrieve. + * + * @return array An associative array combining the folder names as key with + * the corresponding annotation value. + */ + public function listAnnotation($annotation) + { + $this->_timer->push(); + $result = parent::listAnnotation($annotation); + $this->_logger->info( + sprintf( + 'REQUEST OUT IMAP: %s ms [listAnnotation]', + floor($this->_timer->pop() * 1000) + ) + ); + return $result; + } + + /** * Does the given folder exist? * * @param string $folder The folder to check. diff --git a/framework/Kolab_Storage/lib/Horde/Kolab/Storage/List/Base.php b/framework/Kolab_Storage/lib/Horde/Kolab/Storage/List/Base.php index 82cf680c3..7be624b08 100644 --- a/framework/Kolab_Storage/lib/Horde/Kolab/Storage/List/Base.php +++ b/framework/Kolab_Storage/lib/Horde/Kolab/Storage/List/Base.php @@ -111,9 +111,24 @@ implements Horde_Kolab_Storage_List */ public function getQuery($name) { + return $this->getQueryWithParent($name, $this); + } + + /** + * Return the specified query type based on the specified parent object. + * + * @param string $name The query name. + * @param Horde_Kolab_Storage_List $parent The base for the query object. + * + * @return Horde_Kolab_Storage_Query A query handler. + * + * @throws Horde_Kolab_Storage_Exception In case the requested query is not supported. + */ + public function getQueryWithParent($name, Horde_Kolab_Storage_List $parent) + { $class = 'Horde_Kolab_Storage_List_Query_' . $name; if (class_exists($class)) { - return new $class($this); + return new $class($parent); } throw new Horde_Kolab_Storage_Exception(sprintf('No such query "%s"!', $name)); } diff --git a/framework/Kolab_Storage/lib/Horde/Kolab/Storage/List/Decorator/Log.php b/framework/Kolab_Storage/lib/Horde/Kolab/Storage/List/Decorator/Log.php index 074d10d64..7ed0e1aed 100644 --- a/framework/Kolab_Storage/lib/Horde/Kolab/Storage/List/Decorator/Log.php +++ b/framework/Kolab_Storage/lib/Horde/Kolab/Storage/List/Decorator/Log.php @@ -115,7 +115,7 @@ implements Horde_Kolab_Storage_List */ public function getQuery($name) { - return $this->_list->getQuery($name); + return $this->_list->getQueryWithParent($name, $this); } } \ No newline at end of file diff --git a/framework/Kolab_Storage/test/Horde/Kolab/Storage/Unit/Driver/Decorator/LogTest.php b/framework/Kolab_Storage/test/Horde/Kolab/Storage/Unit/Driver/Decorator/LogTest.php index 175303593..881979ac7 100644 --- a/framework/Kolab_Storage/test/Horde/Kolab/Storage/Unit/Driver/Decorator/LogTest.php +++ b/framework/Kolab_Storage/test/Horde/Kolab/Storage/Unit/Driver/Decorator/LogTest.php @@ -54,4 +54,24 @@ extends Horde_Kolab_Storage_TestCase $driver->getMailboxes(); $this->assertLogContains('Driver "Horde_Kolab_Storage_Driver_Mock": List contained 2 folders.'); } + + public function testListAnnotationLogsEntry() + { + $driver = new Horde_Kolab_Storage_Driver_Decorator_Log( + $this->getNullMock(), + $this->getMockLogger() + ); + $driver->listAnnotation('/shared/vendor/kolab/folder-type'); + $this->assertLogCount(2); + } + + public function testListAnnotationFolderCount() + { + $driver = new Horde_Kolab_Storage_Driver_Decorator_Log( + $this->getAnnotatedMock(), + $this->getMockLogger() + ); + $driver->listAnnotation('/shared/vendor/kolab/folder-type'); + $this->assertLogContains('Driver "Horde_Kolab_Storage_Driver_Mock": List contained 4 folder annotations.'); + } } diff --git a/framework/Kolab_Storage/test/Horde/Kolab/Storage/Unit/Driver/Decorator/TimerTest.php b/framework/Kolab_Storage/test/Horde/Kolab/Storage/Unit/Driver/Decorator/TimerTest.php index 7724bcadb..a6bf80b09 100644 --- a/framework/Kolab_Storage/test/Horde/Kolab/Storage/Unit/Driver/Decorator/TimerTest.php +++ b/framework/Kolab_Storage/test/Horde/Kolab/Storage/Unit/Driver/Decorator/TimerTest.php @@ -63,4 +63,26 @@ extends Horde_Kolab_Storage_TestCase $driver->getMailboxes(); $this->assertLogRegExp('/REQUEST OUT IMAP:.*getMailboxes.*/'); } + + public function testListAnnotationLogsEntry() + { + $driver = new Horde_Kolab_Storage_Driver_Decorator_Timer( + $this->getNullMock(), + new Horde_Support_Timer(), + $this->getMockLogger() + ); + $driver->listAnnotation('/shared/vendor/kolab/folder-type'); + $this->assertLogCount(1); + } + + public function testListAnnotationFolderCount() + { + $driver = new Horde_Kolab_Storage_Driver_Decorator_Timer( + $this->getTwoFolderMock(), + new Horde_Support_Timer(), + $this->getMockLogger() + ); + $driver->listAnnotation('/shared/vendor/kolab/folder-type'); + $this->assertLogRegExp('/REQUEST OUT IMAP:.*listAnnotation.*/'); + } }