From f16d2476fc1794bf5819cef3445c37f34accf804 Mon Sep 17 00:00:00 2001 From: Gunnar Wrobel
Date: Thu, 8 Jul 2010 11:45:16 +0200 Subject: [PATCH] Start switching to injected logging. --- .../Kolab_Filter/lib/Horde/Kolab/Filter/Base.php | 35 ++++++++++++++++------ .../test/Horde/Kolab/Filter/FilterTest.php | 6 +++- 2 files changed, 31 insertions(+), 10 deletions(-) diff --git a/framework/Kolab_Filter/lib/Horde/Kolab/Filter/Base.php b/framework/Kolab_Filter/lib/Horde/Kolab/Filter/Base.php index f16784715..55434f152 100644 --- a/framework/Kolab_Filter/lib/Horde/Kolab/Filter/Base.php +++ b/framework/Kolab_Filter/lib/Horde/Kolab/Filter/Base.php @@ -73,10 +73,23 @@ class Horde_Kolab_Filter_Base */ var $_sasl_username; - public function __construct() - { - $GLOBALS['injector'] = $injector = new Horde_Injector(new Horde_Injector_TopLevel()); - $injector->setInstance('Horde_Log_Logger', new Horde_Core_Log_Logger(new Horde_Log_Handler_Mock())); + /** + * The log backend that needs to implement the debug(), info() and err() + * methods. + * + * @param mixed + */ + private $_logger; + + /** + * Constructor. + * + * @param mixed $logger The logger. + */ + public function __construct( + $logger + ) { + $this->_logger = $logger; } /** @@ -105,11 +118,15 @@ class Horde_Kolab_Filter_Base return $result; } - Horde::logMessage(sprintf("%s starting up (sender=%s, recipients=%s, client_address=%s)", - get_class($this), $this->_sender, - join(', ',$this->_recipients), - $this->_client_address), - 'DEBUG'); + $this->_logger->debug( + sprintf( + "%s starting up (sender=%s, recipients=%s, client_address=%s)", + get_class($this), + $this->_sender, + join(', ',$this->_recipients), + $this->_client_address + ) + ); $result = $this->_parse($inh, $transport); if (is_a($result, 'PEAR_Error')) { diff --git a/framework/Kolab_Filter/test/Horde/Kolab/Filter/FilterTest.php b/framework/Kolab_Filter/test/Horde/Kolab/Filter/FilterTest.php index 634f41b77..a033ab4d0 100644 --- a/framework/Kolab_Filter/test/Horde/Kolab/Filter/FilterTest.php +++ b/framework/Kolab_Filter/test/Horde/Kolab/Filter/FilterTest.php @@ -54,7 +54,11 @@ class Horde_Kolab_Filter_FilterTest extends PHPUnit_Framework_TestCase public function testIncorrectUsage() { $_SERVER['argv'] = array($_SERVER['argv'][0]); - $parser = &new Horde_Kolab_Filter_Incoming(); + $parser = new Horde_Kolab_Filter_Incoming( + new Horde_Log_Logger( + new Horde_Log_Handler_Mock() + ) + ); $inh = fopen(dirname(__FILE__) . '/fixtures/tiny.eml', 'r'); try { $result = $parser->parse($inh, 'echo'); -- 2.11.0