Remove logging to a SQL backend - not usually a good use of a relational database...
authorChuck Hagenbuch <chuck@horde.org>
Mon, 24 Jan 2011 03:21:04 +0000 (22:21 -0500)
committerChuck Hagenbuch <chuck@horde.org>
Mon, 24 Jan 2011 03:24:00 +0000 (22:24 -0500)
framework/Log/lib/Horde/Log/Handler/Db.php [deleted file]
framework/Log/package.xml
framework/Log/test/Horde/Log/Handler/DbTest.php [deleted file]

diff --git a/framework/Log/lib/Horde/Log/Handler/Db.php b/framework/Log/lib/Horde/Log/Handler/Db.php
deleted file mode 100644 (file)
index c3cff3d..0000000
+++ /dev/null
@@ -1,83 +0,0 @@
-<?php
-/**
- * Horde Log package
- *
- * This package is based on Zend_Log from the Zend Framework
- * (http://framework.zend.com).  Both that package and this
- * one were written by Mike Naberezny and Chuck Hagenbuch.
- *
- * @author     Mike Naberezny <mike@maintainable.com>
- * @author     Chuck Hagenbuch <chuck@horde.org>
- * @category   Horde
- * @license    http://opensource.org/licenses/bsd-license.php BSD
- * @package    Log
- * @subpackage Handlers
- */
-
-/**
- * @author     Mike Naberezny <mike@maintainable.com>
- * @author     Chuck Hagenbuch <chuck@horde.org>
- * @category   Horde
- * @license    http://opensource.org/licenses/bsd-license.php BSD
- * @package    Log
- * @subpackage Handlers
- */
-class Horde_Log_Handler_Db extends Horde_Log_Handler_Base
-{
-    /**
-     * Database adapter instance.
-     *
-     * @var Horde_Db_Adapter
-     */
-    private $_db;
-
-    /**
-     * Name of the log table in the database.
-     *
-     * @var string
-     */
-    private $_table;
-
-    /**
-     * Options to be set by setOption().
-     * Sets the field names in the database table.
-     *
-     * @var array
-     */
-    protected $_options = array(
-        'fieldMessage' => 'message',
-        'fieldLevel' => 'level'
-    );
-
-    /**
-     * Constructor.
-     *
-     * @param Horde_Db_Adapter $db  Database adapter instance.
-     * @param string $table         Log table in database.
-     */
-    public function __construct($db, $table)
-    {
-        $this->_db = $db;
-        $this->_table = $table;
-    }
-
-    /**
-     * Write a message to the log.
-     *
-     * @param array $event  Log event.
-     *
-     * @return bool  True.
-     */
-    public function write($event)
-    {
-        $fields = array(
-            $this->_options['fieldMessage'] => $event['message'],
-            $this->_options['fieldLevel']   => $event['level'],
-        );
-
-        $this->_db->insert($this->_table, $fields);
-
-        return true;
-    }
-
-}
index 3c807f9..160a548 100644 (file)
@@ -50,7 +50,6 @@ http://pear.php.net/dtd/package-2.0.xsd">
       </dir> <!-- /lib/Horde/Log/Formatter -->
       <dir name="Handler">
        <file name="Base.php" role="php" />
-       <file name="Db.php" role="php" />
        <file name="Firebug.php" role="php" />
        <file name="Mock.php" role="php" />
        <file name="Null.php" role="php" />
@@ -100,7 +99,6 @@ http://pear.php.net/dtd/package-2.0.xsd">
    <install name="lib/Horde/Log/Formatter/Xml.php" as="Horde/Log/Formatter/Xml.php" />
    <install name="lib/Horde/Log/Formatter.php" as="Horde/Log/Formatter.php" />
    <install name="lib/Horde/Log/Handler/Base.php" as="Horde/Log/Handler/Base.php" />
-   <install name="lib/Horde/Log/Handler/Db.php" as="Horde/Log/Handler/Db.php" />
    <install name="lib/Horde/Log/Handler/Firebug.php" as="Horde/Log/Handler/Firebug.php" />
    <install name="lib/Horde/Log/Handler/Mock.php" as="Horde/Log/Handler/Mock.php" />
    <install name="lib/Horde/Log/Handler/Null.php" as="Horde/Log/Handler/Null.php" />
diff --git a/framework/Log/test/Horde/Log/Handler/DbTest.php b/framework/Log/test/Horde/Log/Handler/DbTest.php
deleted file mode 100644 (file)
index 61e7c2e..0000000
+++ /dev/null
@@ -1,84 +0,0 @@
-<?php
-/**
- * Horde Log package
- *
- * This package is based on Zend_Log from the Zend Framework
- * (http://framework.zend.com).  Both that package and this
- * one were written by Mike Naberezny and Chuck Hagenbuch.
- *
- * @author     Mike Naberezny <mike@maintainable.com>
- * @author     Chuck Hagenbuch <chuck@horde.org>
- * @category   Horde
- * @license    http://opensource.org/licenses/bsd-license.php BSD
- * @package    Log
- * @subpackage UnitTests
- */
-
-/**
- * @author     Mike Naberezny <mike@maintainable.com>
- * @author     Chuck Hagenbuch <chuck@horde.org>
- * @category   Horde
- * @license    http://opensource.org/licenses/bsd-license.php BSD
- * @package    Log
- * @subpackage UnitTests
- */
-class Horde_Log_Handler_DbTest extends PHPUnit_Framework_TestCase
-{
-    public function setUp()
-    {
-        $this->tableName = 'db-table-name';
-
-        $this->db      = new Horde_Log_Handler_DbTest_MockDbAdapter();
-        $this->handler = new Horde_Log_Handler_Db($this->db, $this->tableName);
-    }
-
-    public function testWriteWithDefaults()
-    {
-        // log to the mock db adapter
-        $message = 'message-to-log';
-        $level   = 2;
-        $this->handler->write(array('message' => $message, 'level' => $level));
-
-        // insert should be called once...
-        $this->assertContains('insert', array_keys($this->db->calls));
-        $this->assertEquals(1, count($this->db->calls['insert']));
-
-        // ...with the correct table and binds for the database
-        $binds = array('message' => $message,
-                       'level' => $level);
-        $this->assertEquals(array($this->tableName, $binds),
-                            $this->db->calls['insert'][0]);
-    }
-
-    public function testWriteUsesOptionalCustomColumns()
-    {
-        $this->handler->setOption('fieldMessage', $messageField = 'new-message-field');
-        $this->handler->setOption('fieldLevel',   $levelField   = 'new-level-field');
-
-        // log to the mock db adapter
-        $message = 'message-to-log';
-        $level   = 2;
-        $this->handler->write(array('message' => $message, 'level' => $level));
-
-        // insert should be called once...
-        $this->assertContains('insert', array_keys($this->db->calls));
-        $this->assertEquals(1, count($this->db->calls['insert']));
-
-        // ...with the correct table and binds for the database
-        $binds = array($messageField => $message,
-                       $levelField   => $level);
-        $this->assertEquals(array($this->tableName, $binds),
-                            $this->db->calls['insert'][0]);
-    }
-}
-
-
-class Horde_Log_Handler_DbTest_MockDbAdapter
-{
-    public $calls = array();
-
-    public function __call($method, $params)
-    {
-        $this->calls[$method][] = $params;
-    }
-}