Start switching to injected logging.
authorGunnar Wrobel <p@rdus.de>
Thu, 8 Jul 2010 09:45:16 +0000 (11:45 +0200)
committerGunnar Wrobel <p@rdus.de>
Wed, 25 Aug 2010 17:21:36 +0000 (19:21 +0200)
framework/Kolab_Filter/lib/Horde/Kolab/Filter/Base.php
framework/Kolab_Filter/test/Horde/Kolab/Filter/FilterTest.php

index f167847..55434f1 100644 (file)
@@ -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')) {
index 634f41b..a033ab4 100644 (file)
@@ -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');