First pass at passing Logger to framework libs using injector/binder
authorMichael M Slusarz <slusarz@curecanti.org>
Wed, 17 Mar 2010 07:04:30 +0000 (01:04 -0600)
committerMichael M Slusarz <slusarz@curecanti.org>
Wed, 17 Mar 2010 18:13:05 +0000 (12:13 -0600)
18 files changed:
framework/Cache/lib/Horde/Cache/Base.php
framework/Cache/lib/Horde/Cache/Sql.php
framework/Cache/package.xml
framework/Core/lib/Horde/Core/Binder/Cache.php
framework/Core/lib/Horde/Core/Binder/Memcache.php
framework/Core/lib/Horde/Core/Binder/Notification.php
framework/Core/lib/Horde/Core/Binder/Perms.php
framework/Core/lib/Horde/Core/Binder/Template.php
framework/Core/lib/Horde/Core/Notification/Hordelog.php [new file with mode: 0644]
framework/Core/package.xml
framework/Memcache/lib/Horde/Memcache.php
framework/Notification/lib/Horde/Notification/Handler/Decorator/Hordelog.php [deleted file]
framework/Notification/package.xml
framework/Perms/lib/Horde/Perms.php
framework/Perms/lib/Horde/Perms/Datatree.php
framework/Perms/lib/Horde/Perms/Sql.php
framework/Template/lib/Horde/Template.php
framework/Template/package.xml

index a83649f..d862587 100644 (file)
@@ -23,9 +23,21 @@ abstract class Horde_Cache_Base
     protected $_params = array();
 
     /**
+     * Logger.
+     *
+     * @var Horde_Log_Logger
+     */
+    protected $_logger;
+
+    /**
      * Construct a new Horde_Cache object.
      *
-     * @param array $params  Parameter array.
+     * @param array $params  Parameter array:
+     * <pre>
+     * 'lifetime' - (integer) Lifetime of data, in seconds.
+     *              DEFAULT: 86400 seconds
+     * 'logger' - (Horde_Log_Logger) Log object to use for log/debug messages.
+     * </pre>
      */
     public function __construct($params = array())
     {
@@ -35,6 +47,11 @@ abstract class Horde_Cache_Base
                 : 86400;
         }
 
+        if (isset($params['logger'])) {
+            $this->_logger = $params['logger'];
+            unset($params['logger']);
+        }
+
         $this->_params = $params;
     }
 
index 1933c97..0cf615d 100644 (file)
@@ -122,7 +122,9 @@ class Horde_Cache_Sql extends Horde_Cache_Base
         try {
             $this->_connect();
         } catch (Horde_Exception $e) {
-            Horde::logMessage($e, 'ERR');
+            if ($this->_logger) {
+                $this->_logger->log($e, 'ERR');
+            }
             return;
         }
 
@@ -132,7 +134,9 @@ class Horde_Cache_Sql extends Horde_Cache_Base
 
         $result = $this->_write_db->query($query, $values);
         if (is_a($result, 'PEAR_Error')) {
-            Horde::logMessage($result, 'ERR');
+            if ($this->_logger) {
+                $this->_logger->log($result, 'ERR');
+            }
         }
     }
 
@@ -160,7 +164,9 @@ class Horde_Cache_Sql extends Horde_Cache_Base
         try {
             $this->_connect();
         } catch (Horde_Exception $e) {
-            Horde::logMessage($e, 'ERR');
+            if ($this->_logger) {
+                $this->_logger->log($e, 'ERR');
+            }
             return false;
         }
 
@@ -180,18 +186,25 @@ class Horde_Cache_Sql extends Horde_Cache_Base
 
         $result = $this->_db->getOne($query, $values);
         if (is_a($result, 'PEAR_Error')) {
-            Horde::logMessage($result, 'ERR');
+            if ($this->_logger) {
+                $this->_logger->log($result, 'ERR');
+            }
             return false;
         } elseif (is_null($result)) {
             /* No rows were found - cache miss */
-            Horde::logMessage(sprintf('Cache miss: %s (Id %s newer than %d)', $okey, $key, $maxage), 'DEBUG');
+            if ($this->_logger) {
+                $this->_logger->log(sprintf('Cache miss: %s (Id %s newer than %d)', $okey, $key, $maxage), 'DEBUG');
+            }
             return false;
         }
 
         if ($this->_mc) {
             $this->_mc->set($key, $result);
         }
-        Horde::logMessage(sprintf('Cache hit: %s (Id %s newer than %d)', $okey, $key, $maxage), 'DEBUG');
+
+        if ($this->_logger) {
+            $this->_logger->log(sprintf('Cache hit: %s (Id %s newer than %d)', $okey, $key, $maxage), 'DEBUG');
+        }
 
         return $result;
     }
@@ -218,7 +231,9 @@ class Horde_Cache_Sql extends Horde_Cache_Base
         try {
             $this->_connect();
         } catch (Horde_Exception $e) {
-            Horde::logMessage($e, 'ERR');
+            if ($this->_logger) {
+                $this->_logger->log($e, 'ERR');
+            }
             return false;
         }
 
@@ -229,7 +244,9 @@ class Horde_Cache_Sql extends Horde_Cache_Base
             ? 0
             : $this->_getLifetime($lifetime) + $timestamp;
 
-        Horde::logMessage(sprintf('Cache set: %s (Id %s set at %d expires at %d)', $okey, $key, $timestamp, $expiration), 'DEBUG');
+            if ($this->_logger) {
+                $this->_logger->log(sprintf('Cache set: %s (Id %s set at %d expires at %d)', $okey, $key, $timestamp, $expiration), 'DEBUG');
+            }
 
         // Remove any old cache data and prevent duplicate keys
         $query = 'DELETE FROM ' . $this->_params['table'] . ' WHERE cache_id=?';
@@ -244,7 +261,9 @@ class Horde_Cache_Sql extends Horde_Cache_Base
 
         $result = $this->_write_db->query($query, $values);
         if (is_a($result, 'PEAR_Error')) {
-            Horde::logMessage($result, 'ERR');
+            if ($this->_logger) {
+                $this->_logger->log($result, 'ERR');
+            }
             return false;
         }
 
@@ -273,7 +292,9 @@ class Horde_Cache_Sql extends Horde_Cache_Base
         try {
             $this->_connect();
         } catch (Horde_Exception $e) {
-            Horde::logMessage($e, 'ERR');
+            if ($this->_logger) {
+                $this->_logger->log($e, 'ERR');
+            }
             return false;
         }
 
@@ -290,16 +311,23 @@ class Horde_Cache_Sql extends Horde_Cache_Base
 
         $result = $this->_db->getRow($query, $values);
         if (is_a($result, 'PEAR_Error')) {
-            Horde::logMessage($result, 'ERR');
+            if ($this->_logger) {
+                $this->_logger->log($result, 'ERR');
+            }
             return false;
         }
 
         $timestamp = time();
         if (empty($result)) {
-            Horde::logMessage(sprintf('Cache exists() miss: %s (Id %s newer than %d)', $okey, $key, $timestamp), 'DEBUG');
+            if ($this->_logger) {
+                $this->_logger->log(sprintf('Cache exists() miss: %s (Id %s newer than %d)', $okey, $key, $timestamp), 'DEBUG');
+            }
             return false;
         }
-        Horde::logMessage(sprintf('Cache exists() hit: %s (Id %s newer than %d)', $okey, $key, $timestamp), 'DEBUG');
+
+        if ($this->_logger) {
+            $this->_logger->log(sprintf('Cache exists() hit: %s (Id %s newer than %d)', $okey, $key, $timestamp), 'DEBUG');
+        }
 
         return true;
     }
@@ -322,7 +350,9 @@ class Horde_Cache_Sql extends Horde_Cache_Base
         try {
             $this->_connect();
         } catch (Horde_Exception $e) {
-            Horde::logMessage($e, 'ERR');
+            if ($this->_logger) {
+                $this->_logger->log($e, 'ERR');
+            }
             return false;
         }
 
@@ -332,7 +362,9 @@ class Horde_Cache_Sql extends Horde_Cache_Base
 
         $result = $this->_write_db->query($query, $values);
         if (is_a($result, 'PEAR_Error')) {
-            Horde::logMessage($result, 'ERR');
+            if ($this->_logger) {
+                $this->_logger->log($result, 'ERR');
+            }
             return false;
         }
 
index 4ac63a6..deabc2c 100644 (file)
@@ -33,7 +33,8 @@ Performance Suite&apos;s content cache), memcached, or an SQL table.
   <api>beta</api>
  </stability>
  <license uri="http://www.gnu.org/copyleft/lesser.html">LGPL</license>
- <notes>* Initial Horde 4 package.</notes>
+ <notes>* Removed dependency on Horde Core.
+ * Initial Horde 4 package.</notes>
  <contents>
   <dir name="/">
    <dir name="data">
@@ -80,6 +81,10 @@ Performance Suite&apos;s content cache), memcached, or an SQL table.
    <extension>
     <name>memcache</name>
    </extension>
+   <package>
+    <name>Log</name>
+    <channel>pear.horde.org</channel>
+   </package>
   </optional>
  </dependencies>
  <phprelease>
index f704c2a..4dfaead 100644 (file)
@@ -31,6 +31,8 @@ class Horde_Core_Binder_Cache implements Horde_Injector_Binder
             }
         }
 
+        $params['logger'] = $injector->getInstance('Horde_Log_Logger');
+
         return Horde_Cache::factory($driver, $params);
     }
 
index d10b95b..8a7d828 100644 (file)
@@ -5,7 +5,7 @@ class Horde_Core_Binder_Memcache implements Horde_Injector_Binder
     {
         return empty($GLOBALS['conf']['memcache']['enabled'])
             ? null
-            : new Horde_Memcache($GLOBALS['conf']['memcache']);
+            : new Horde_Memcache(array_merge($GLOBALS['conf']['memcache'], array('logger' => $injector->getInstance('Horde_Log_Logger'))));
     }
 
     public function equals(Horde_Injector_Binder $binder)
index 780dda7..dd3b32d 100644 (file)
@@ -9,7 +9,7 @@ class Horde_Core_Binder_Notification implements Horde_Injector_Binder
         $notify->addType('status', 'horde.*', 'Horde_Core_Notification_Status');
 
         $notify->addDecorator(new Horde_Notification_Handler_Decorator_Alarm(Horde_Alarm::factory(), Horde_Auth::getAuth()));
-        $notify->addDecorator(new Horde_Notification_Handler_Decorator_Hordelog());
+        $notify->addDecorator(new Horde_Core_Notification_Hordelog());
 
         return $notify;
     }
index a3ad522..9e3de99 100644 (file)
@@ -3,15 +3,27 @@ class Horde_Core_Binder_Perms implements Horde_Injector_Binder
 {
     public function create(Horde_Injector $injector)
     {
-        $perm_driver = $perm_params = null;
+        $perm_params = array(
+            'cache' => $injector->getInstance('Horde_Cache'),
+            'logger' => $injector->getInstance('Horde_Logger')
+        );
 
-        if (empty($GLOBALS['conf']['perms']['driver'])) {
-            $perm_driver = empty($GLOBALS['conf']['datatree']['driver'])
-                ? null
-                : 'datatree';
-        } else {
-            $perm_driver = $GLOBALS['conf']['perms']['driver'];
-            $perm_params = Horde::getDriverConfig('perms', $perm_driver);
+        $perm_driver = empty($GLOBALS['conf']['perms']['driver'])
+            ? (empty($GLOBALS['conf']['datatree']['driver']) ? null : 'datatree')
+            : $GLOBALS['conf']['perms']['driver'];
+
+        switch (strtolower($perm_driver)) {
+        case 'datatree':
+            $driver = $GLOBALS['conf']['datatree']['driver'];
+            $perm_params['datatree'] = DataTree::singleton(
+                $driver,
+                array_merge(Horde::getDriverConfig('datatree', $driver), array('group' => 'horde.perms'))
+            );
+            break;
+
+        case 'sql':
+            // TODO
+            break;
         }
 
         return Horde_Perms::factory($perm_driver, $perm_params);
index 825f19b..3622006 100644 (file)
@@ -4,7 +4,8 @@ class Horde_Core_Binder_Template implements Horde_Injector_Binder
     public function create(Horde_Injector $injector)
     {
         return new Horde_Template(array(
-            'cacheob' => $injector->getInstance('Horde_Cache')
+            'cacheob' => $injector->getInstance('Horde_Cache'),
+            'logger' => $injector->getInstance('Horde_Log_Logger')
         ));
     }
 
diff --git a/framework/Core/lib/Horde/Core/Notification/Hordelog.php b/framework/Core/lib/Horde/Core/Notification/Hordelog.php
new file mode 100644 (file)
index 0000000..4018f16
--- /dev/null
@@ -0,0 +1,29 @@
+<?php
+/**
+ * The Hordelog Decorator logs error events via Horde::logMessage().
+ *
+ * Copyright 2001-2010 The Horde Project (http://www.horde.org/)
+ *
+ * See the enclosed file COPYING for license information (LGPL). If you
+ * did not receive this file, see http://www.fsf.org/copyleft/lgpl.html.
+ *
+ * @author  Jan Schneider <jan@horde.org>
+ * @package Horde_Core
+ */
+class Horde_Core_Notification_Hordelog
+extends Horde_Notification_Handler_Decorator_Base
+{
+    /**
+     * Event is being added to the Horde message stack.
+     *
+     * @param Horde_Notification_Event $event  Event object.
+     * @param array $options                   Additional options (see
+     *                                         Horde_Notification_Handler for
+     *                                         details).
+     */
+    public function push(Horde_Notification_Event $event, $options)
+    {
+        Horde::logMessage($event->message, 'DEBUG');
+    }
+
+}
index e20b076..b09e9b6 100644 (file)
@@ -80,6 +80,7 @@ Application Framework.
        <file name="Logger.php" role="php" />
       </dir> <!-- /lib/Horde/Core/Log -->
       <dir name="Notification">
+       <file name="Hordelog.php" role="php" />
        <file name="Status.php" role="php" />
       </dir> <!-- /lib/Horde/Core/Notification -->
      </dir> <!-- /lib/Horde/Core -->
@@ -190,6 +191,7 @@ Application Framework.
    <install name="lib/Horde/Core/Binder/Template.php" as="Horde/Core/Binder/Template.php" />
    <install name="lib/Horde/Core/Factory/KolabServer.php" as="Horde/Core/Factory/KolabServer.php" />
    <install name="lib/Horde/Core/Log/Logger.php" as="Horde/Core/Log/Logger.php" />
+   <install name="lib/Horde/Core/Notification/Hordelog.php" as="Horde/Core/Notification/Hordelog.php" />
    <install name="lib/Horde/Core/Notification/Status.php" as="Horde/Core/Notification/Status.php" />
    <install name="lib/Horde/ErrorHandler.php" as="Horde/ErrorHandler.php" />
    <install name="lib/Horde/Exception/HookNotSet.php" as="Horde/Exception/HookNotSet.php" />
index 96fad41..a2eea71 100644 (file)
@@ -87,6 +87,13 @@ class Horde_Memcache
     protected $_noexist = array();
 
     /**
+     * Logger instance.
+     *
+     * @var Horde_Log_Logger
+     */
+    protected $_logger;
+
+    /**
      * Constructor.
      *
      * @param array $params  TODO
@@ -99,6 +106,10 @@ class Horde_Memcache
         $this->_params['prefix'] = (empty($this->_params['prefix'])) ? 'horde' : $this->_params['prefix'];
         $this->_large = !empty($this->_params['large_items']);
 
+        if (isset($params['logger'])) {
+            $this->_logger = $params['logger'];
+        }
+
         $this->__wakeup();
     }
 
@@ -129,7 +140,9 @@ class Horde_Memcache
         // Force consistent hashing
         ini_set('memcache.hash_strategy', 'consistent');
 
-        Horde::logMessage('Connected to the following memcache servers:' . implode($servers, ', '), 'DEBUG');
+        if ($this->_logger) {
+            $this->_logger->log('Connected to the following memcache servers:' . implode($servers, ', '), 'DEBUG');
+        }
     }
 
     /**
diff --git a/framework/Notification/lib/Horde/Notification/Handler/Decorator/Hordelog.php b/framework/Notification/lib/Horde/Notification/Handler/Decorator/Hordelog.php
deleted file mode 100644 (file)
index b85cb75..0000000
+++ /dev/null
@@ -1,29 +0,0 @@
-<?php
-/**
- * The Hordelog Decorator logs error events via Horde::logMessage().
- *
- * Copyright 2001-2010 The Horde Project (http://www.horde.org/)
- *
- * See the enclosed file COPYING for license information (LGPL). If you
- * did not receive this file, see http://www.fsf.org/copyleft/lgpl.html.
- *
- * @author  Jan Schneider <jan@horde.org>
- * @package Horde_Notification
- */
-class Horde_Notification_Handler_Decorator_Hordelog
-extends Horde_Notification_Handler_Decorator_Base
-{
-    /**
-     * Event is being added to the Horde message stack.
-     *
-     * @param Horde_Notification_Event $event  Event object.
-     * @param array $options                   Additional options (see
-     *                                         Horde_Notification_Handler for
-     *                                         details).
-     */
-    public function push(Horde_Notification_Event $event, $options)
-    {
-        Horde::logMessage($event->message, 'DEBUG');
-    }
-
-}
index e3cafaf..cf81867 100644 (file)
@@ -40,7 +40,6 @@ http://pear.php.net/dtd/package-2.0.xsd">
        <dir name="Decorator">
         <file name="Alarm.php" role="php" />
         <file name="Base.php" role="php" />
-        <file name="Hordelog.php" role="php" />
         <file name="Log.php" role="php" />
        </dir> <!-- /lib/Horde/Notification/Handler/Decorator -->
       </dir> <!-- /lib/Horde/Notification/Handler -->
@@ -73,7 +72,6 @@ http://pear.php.net/dtd/package-2.0.xsd">
         <dir name="Handler">
          <dir name="Decorator">
           <file name="AlarmTest.php" role="test" />
-          <file name="HordelogTest.php" role="test" />
           <file name="LogTest.php" role="test" />
          </dir> <!-- /test/Horde/Notification/Class/Notification/Handler/Decorator -->
         </dir> <!-- /test/Horde/Notification/Class/Notification/Handler -->
@@ -123,7 +121,6 @@ http://pear.php.net/dtd/package-2.0.xsd">
    <install name="lib/Horde/Notification/Event/Status.php" as="Horde/Notification/Event/Status.php" />
    <install name="lib/Horde/Notification/Handler/Decorator/Alarm.php" as="Horde/Notification/Handler/Decorator/Alarm.php" />
    <install name="lib/Horde/Notification/Handler/Decorator/Base.php" as="Horde/Notification/Handler/Decorator/Base.php" />
-   <install name="lib/Horde/Notification/Handler/Decorator/Hordelog.php" as="Horde/Notification/Handler/Decorator/Hordelog.php" />
    <install name="lib/Horde/Notification/Handler/Decorator/Log.php" as="Horde/Notification/Handler/Decorator/Log.php" />
    <install name="lib/Horde/Notification/Listener/Audio.php" as="Horde/Notification/Listener/Audio.php" />
    <install name="lib/Horde/Notification/Listener/Javascript.php" as="Horde/Notification/Listener/Javascript.php" />
@@ -140,7 +137,6 @@ http://pear.php.net/dtd/package-2.0.xsd">
    <install name="test/Horde/Notification/Class/Notification/HandlerTest.php" as="Horde/Notification/Class/Notification/HandlerTest.php" />
    <install name="test/Horde/Notification/Class/Notification/EventTest.php" as="Horde/Notification/Class/Notification/EventTest.php" />
    <install name="test/Horde/Notification/Class/Notification/Handler/Decorator/AlarmTest.php" as="Horde/Notification/Class/Notification/Handler/Decorator/AlarmTest.php" />
-   <install name="test/Horde/Notification/Class/Notification/Handler/Decorator/HordelogTest.php" as="Horde/Notification/Class/Notification/Handler/Decorator/HordelogTest.php" />
    <install name="test/Horde/Notification/Class/Notification/Handler/Decorator/LogTest.php" as="Horde/Notification/Class/Notification/Handler/Decorator/LogTest.php" />
    <install name="test/Horde/Notification/Class/Notification/ListenerTest.php" as="Horde/Notification/Class/Notification/ListenerTest.php" />
    <install name="test/Horde/Notification/Class/Notification/Listener/AudioTest.php" as="Horde/Notification/Class/Notification/Listener/AudioTest.php" />
index 4911b8a..4b6a0da 100644 (file)
@@ -32,6 +32,20 @@ class Horde_Perms
     const ROOT = -1;
 
     /**
+     * Cache object.
+     *
+     * @var Horde_Cache
+     */
+    protected $_cache;
+
+    /**
+     * Logger.
+     *
+     * @var Horde_Log_Logger
+     */
+    protected $_logger;
+
+    /**
      * Caches information about application permissions.
      *
      * @var array
@@ -76,6 +90,28 @@ class Horde_Perms
     }
 
     /**
+     * Constructor.
+     *
+     * @param array $params  Configuration parameters:
+     * <pre>
+     * 'cache' - (Horde_Cache) The object to use to cache perms.
+     * 'logger' - (Horde_Log_Logger) A logger object.
+     * </pre>
+     *
+     * @throws Horde_Perms_Exception
+     */
+    public function __construct($params = array())
+    {
+        if (isset($params['cache'])) {
+            $this->_cache = $params['cache'];
+        }
+
+        if (isset($params['logger'])) {
+            $this->_logger = $params['logger'];
+        }
+    }
+
+    /**
      * Returns the available permissions for a given level.
      *
      * @param string $name  The permission's name.
@@ -299,7 +335,9 @@ class Horde_Perms
             try {
                 $permission = $this->getPermission($permission);
             } catch (Horde_Perms_Exception $e) {
-                Horde::logMessage($e, 'DEBUG');
+                if ($this->_logger) {
+                    $this->_logger->log($e, 'DEBUG');
+                }
                 return false;
             }
         }
index ff17884..b1a6d10 100644 (file)
@@ -23,13 +23,6 @@ class Horde_Perms_Datatree extends Horde_Perms
     protected $_datatree;
 
     /**
-     * Pointer to a Horde_Cache instance.
-     *
-     * @var Horde_Cache
-     */
-    protected $_cache;
-
-    /**
      * Incrementing version number if cached classes change.
      *
      * @var integer
@@ -46,22 +39,23 @@ class Horde_Perms_Datatree extends Horde_Perms
     /**
      * Constructor.
      *
-     * @throws Horde_Exception
+     * @param array $params  Configuration parameters (in addition to base
+     *                       Horde_Perms parameters):
+     * <pre>
+     * 'datatree' - (DataTree) A datatree object. [REQUIRED]
+     * </pre>
+     *
+     * @throws Horde_Perms_Exception
      */
-    public function __construct()
+    public function __construct($params = array())
     {
-        global $conf;
-
-        if (empty($conf['datatree']['driver'])) {
-            throw new Horde_Exception('You must configure a DataTree backend.');
+        if (empty($params['datatree'])) {
+            throw new Horde_Perms_Exception('You must configure a DataTree backend.');
         }
 
-        $driver = $conf['datatree']['driver'];
-        $this->_datatree = DataTree::singleton($driver,
-                                               array_merge(Horde::getDriverConfig('datatree', $driver),
-                                                           array('group' => 'horde.perms')));
+        $this->_datatree = $params['datatree'];
 
-        $this->_cache = $GLOBALS['injector']->getInstance('Horde_Cache');
+        parent::__construct($params);
     }
 
     /**
index c843f30..8dda934 100644 (file)
@@ -37,13 +37,6 @@ class Horde_Perms_Sql extends Horde_Perms
     protected $_write_db;
 
     /**
-     * Pointer to a Horde_Cache instance
-     *
-     * @var Horde_Cache
-     */
-    protected $_cache;
-
-    /**
      * Incrementing version number if cached classes change.
      *
      * @var integer
@@ -59,10 +52,18 @@ class Horde_Perms_Sql extends Horde_Perms
 
     /**
      * Constructor.
+     *
+     * @param array $params  Configuration parameters (in addition to base
+     *                       Horde_Perms parameters):
+     * <pre>
+     * NONE (TODO - pass in SQL object)
+     * </pre>
+     *
+     * @throws Horde_Perms_Exception
      */
-    public function __construct()
+    public function __construct($params = array())
     {
-        $this->_cache = $GLOBALS['injector']->getInstance('Horde_Cache');
+        parent::__construct($params);
     }
 
     /**
index 616e45f..90ce4d1 100644 (file)
@@ -35,6 +35,13 @@ class Horde_Template
     protected $_cache;
 
     /**
+     * Logger.
+     *
+     * @var Horde_Log_Logger
+     */
+    protected $_logger;
+
+    /**
      * Option values.
      *
      * @var array
@@ -104,9 +111,10 @@ class Horde_Template
      * <pre>
      * 'basepath' - (string) The directory where templates are read from.
      * 'cacheob' - (Horde_Cache) A caching object used to cache the output.
+     * 'logger' - (Horde_Log_Logger) A logger object.
      * </pre>
      */
-    public function __construct($basepath = null)
+    public function __construct($params = array())
     {
         if (isset($params['basepath'])) {
             $this->_basepath = $params['basepath'];
@@ -115,6 +123,10 @@ class Horde_Template
         if (isset($params['cacheob'])) {
             $this->_cache = $params['cacheob'];
         }
+
+        if (isset($params['logger'])) {
+            $this->_logger = $params['logger'];
+        }
     }
 
     /**
@@ -230,8 +242,9 @@ class Horde_Template
             $this->_parse();
             if ($this->_cache &&
                 isset($cacheid) &&
-                !$this->_cache->set($cacheid, $this->_template)) {
-                Horde::logMessage(sprintf(_("Could not save the compiled template file '%s'."), $file), 'ERR');
+                !$this->_cache->set($cacheid, $this->_template) &&
+                $this->_logger) {
+                $this->_logger->log(sprintf('Could not save the compiled template file "%s".', $file), 'ERR');
             }
         }
 
index 56c35cf..f960795 100644 (file)
@@ -30,7 +30,8 @@ http://pear.php.net/dtd/package-2.0.xsd">
   <api>beta</api>
  </stability>
  <license uri="http://www.gnu.org/copyleft/lesser.html">LGPL</license>
- <notes>* Initial Horde 4 package.
+ <notes>* Remove dependency on Horde_Core.
+ * Initial Horde 4 package.
  </notes>
  <contents>
   <dir name="/">