--- /dev/null
+<?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.
+ *
+ * @category Horde
+ * @package Horde_Log
+ * @subpackage Filters
+ * @author Mike Naberezny <mike@maintainable.com>
+ * @author Chuck Hagenbuch <chuck@horde.org>
+ * @license http://opensource.org/licenses/bsd-license.php BSD
+ */
+
+/**
+ * @category Horde
+ * @package Horde_Log
+ * @subpackage Filters
+ * @author Mike Naberezny <mike@maintainable.com>
+ * @author Chuck Hagenbuch <chuck@horde.org>
+ * @license http://opensource.org/licenses/bsd-license.php BSD
+ */
+class Horde_Log_Filter_Suppress implements Horde_Log_Filter_Interface
+{
+ /**
+ * @var boolean
+ */
+ protected $_accept = true;
+
+ /**
+ * This is a simple boolean filter.
+ *
+ * Call suppress(true) to suppress all log events.
+ * Call suppress(false) to accept all log events.
+ *
+ * @param boolean $suppress Should all log events be suppressed?
+ * @return void
+ */
+ public function suppress($suppress)
+ {
+ $this->_accept = (! $suppress);
+ }
+
+ /**
+ * Returns TRUE to accept the message, FALSE to block it.
+ *
+ * @param array $event event data
+ * @return boolean accepted?
+ */
+ public function accept($event)
+ {
+ return $this->_accept;
+ }
+
+}
<email>mike@maintainable.com</email>
<active>yes</active>
</lead>
- <date>2007-10-21</date>
+ <date>2009-02-09</date>
<time>23:26:00</time>
<version>
- <release>0.1.0</release>
- <api>0.1.0</api>
+ <release>0.2.0</release>
+ <api>0.2.0</api>
</version>
<stability>
<release>beta</release>
<api>beta</api>
</stability>
<license uri="http://opensource.org/licenses/bsd-license.php">BSD</license>
- <notes>Initial Horde_Log release
+ <notes>* Added Horde_Log_Filter_Suppress.
</notes>
<contents>
<dir name="/">
<file name="Interface.php" role="php" />
<file name="Level.php" role="php" />
<file name="Message.php" role="php" />
+ <file name="Suppress.php" role="php" />
</dir> <!-- /lib/Horde/Log/Filter -->
<dir name="Formatter">
<file name="Interface.php" role="php" />
<install name="lib/Horde/Log/Filter/Interface.php" as="Horde/Log/Filter/Interface.php" />
<install name="lib/Horde/Log/Filter/Level.php" as="Horde/Log/Filter/Level.php" />
<install name="lib/Horde/Log/Filter/Message.php" as="Horde/Log/Filter/Message.php" />
+ <install name="lib/Horde/Log/Filter/Suppress.php" as="Horde/Log/Filter/Suppress.php" />
<install name="lib/Horde/Log/Formatter/Interface.php" as="Horde/Log/Formatter/Interface.php" />
<install name="lib/Horde/Log/Formatter/Simple.php" as="Horde/Log/Formatter/Simple.php" />
<install name="lib/Horde/Log/Formatter/Xml.php" as="Horde/Log/Formatter/Xml.php" />
--- /dev/null
+<?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.
+ *
+ * @category Horde
+ * @package Horde_Log
+ * @subpackage UnitTests
+ * @author Mike Naberezny <mike@maintainable.com>
+ * @author Chuck Hagenbuch <chuck@horde.org>
+ * @license http://opensource.org/licenses/bsd-license.php BSD
+ */
+
+/**
+ * @category Horde
+ * @package Horde_Log
+ * @subpackage UnitTests
+ * @author Mike Naberezny <mike@maintainable.com>
+ * @author Chuck Hagenbuch <chuck@horde.org>
+ * @license http://opensource.org/licenses/bsd-license.php BSD
+ */
+class Horde_Log_Filter_SuppressTest extends PHPUnit_Framework_TestCase
+{
+ public function setUp()
+ {
+ $this->filter = new Horde_Log_Filter_Suppress();
+ }
+
+ public function testSuppressIsInitiallyOff()
+ {
+ $this->assertTrue($this->filter->accept(array()));
+ }
+
+ public function testSuppressOn()
+ {
+ $this->filter->suppress(true);
+ $this->assertFalse($this->filter->accept(array()));
+ $this->assertFalse($this->filter->accept(array()));
+ }
+
+ public function testSuppressOff()
+ {
+ $this->filter->suppress(false);
+ $this->assertTrue($this->filter->accept(array()));
+ $this->assertTrue($this->filter->accept(array()));
+ }
+
+ public function testSuppressCanBeReset()
+ {
+ $this->filter->suppress(true);
+ $this->assertFalse($this->filter->accept(array()));
+ $this->filter->suppress(false);
+ $this->assertTrue($this->filter->accept(array()));
+ $this->filter->suppress(true);
+ $this->assertFalse($this->filter->accept(array()));
+ }
+}