diff options
Diffstat (limited to 'library/vendor/Zend/Log/Filter')
-rw-r--r-- | library/vendor/Zend/Log/Filter/Abstract.php | 57 | ||||
-rw-r--r-- | library/vendor/Zend/Log/Filter/Interface.php | 40 | ||||
-rw-r--r-- | library/vendor/Zend/Log/Filter/Message.php | 83 | ||||
-rw-r--r-- | library/vendor/Zend/Log/Filter/Priority.php | 99 | ||||
-rw-r--r-- | library/vendor/Zend/Log/Filter/Suppress.php | 76 |
5 files changed, 355 insertions, 0 deletions
diff --git a/library/vendor/Zend/Log/Filter/Abstract.php b/library/vendor/Zend/Log/Filter/Abstract.php new file mode 100644 index 0000000..53cd40c --- /dev/null +++ b/library/vendor/Zend/Log/Filter/Abstract.php @@ -0,0 +1,57 @@ +<?php +/** + * Zend Framework + * + * LICENSE + * + * This source file is subject to the new BSD license that is bundled + * with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://framework.zend.com/license/new-bsd + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@zend.com so we can send you a copy immediately. + * + * @category Zend + * @package Zend_Log + * @subpackage Writer + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) + * @license http://framework.zend.com/license/new-bsd New BSD License + * @version $Id$ + */ + +/** @see Zend_Log_Filter_Interface */ + +/** @see Zend_Log_FactoryInterface */ + +/** + * @category Zend + * @package Zend_Log + * @subpackage Filter + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) + * @license http://framework.zend.com/license/new-bsd New BSD License + * @version $Id$ + */ +abstract class Zend_Log_Filter_Abstract + implements Zend_Log_Filter_Interface, Zend_Log_FactoryInterface +{ + /** + * Validate and optionally convert the config to array + * + * @param array|Zend_Config $config Zend_Config or Array + * @return array + * @throws Zend_Log_Exception + */ + static protected function _parseConfig($config) + { + if ($config instanceof Zend_Config) { + $config = $config->toArray(); + } + + if (!is_array($config)) { + throw new Zend_Log_Exception('Configuration must be an array or instance of Zend_Config'); + } + + return $config; + } +} diff --git a/library/vendor/Zend/Log/Filter/Interface.php b/library/vendor/Zend/Log/Filter/Interface.php new file mode 100644 index 0000000..dc0cbad --- /dev/null +++ b/library/vendor/Zend/Log/Filter/Interface.php @@ -0,0 +1,40 @@ +<?php +/** + * Zend Framework + * + * LICENSE + * + * This source file is subject to the new BSD license that is bundled + * with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://framework.zend.com/license/new-bsd + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@zend.com so we can send you a copy immediately. + * + * @category Zend + * @package Zend_Log + * @subpackage Filter + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) + * @license http://framework.zend.com/license/new-bsd New BSD License + * @version $Id$ + */ + +/** + * @category Zend + * @package Zend_Log + * @subpackage Filter + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) + * @license http://framework.zend.com/license/new-bsd New BSD License + * @version $Id$ + */ +interface Zend_Log_Filter_Interface +{ + /** + * Returns TRUE to accept the message, FALSE to block it. + * + * @param array $event event data + * @return boolean accepted? + */ + public function accept($event); +} diff --git a/library/vendor/Zend/Log/Filter/Message.php b/library/vendor/Zend/Log/Filter/Message.php new file mode 100644 index 0000000..3b98f92 --- /dev/null +++ b/library/vendor/Zend/Log/Filter/Message.php @@ -0,0 +1,83 @@ +<?php +/** + * Zend Framework + * + * LICENSE + * + * This source file is subject to the new BSD license that is bundled + * with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://framework.zend.com/license/new-bsd + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@zend.com so we can send you a copy immediately. + * + * @category Zend + * @package Zend_Log + * @subpackage Filter + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) + * @license http://framework.zend.com/license/new-bsd New BSD License + * @version $Id$ + */ + +/** Zend_Log_Filter_Abstract */ + +/** + * @category Zend + * @package Zend_Log + * @subpackage Filter + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) + * @license http://framework.zend.com/license/new-bsd New BSD License + * @version $Id$ + */ +class Zend_Log_Filter_Message extends Zend_Log_Filter_Abstract +{ + /** + * @var string + */ + protected $_regexp; + + /** + * Filter out any log messages not matching $regexp. + * + * @param string $regexp Regular expression to test the log message + * @return void + * @throws Zend_Log_Exception + */ + public function __construct($regexp) + { + if (@preg_match($regexp, '') === false) { + throw new Zend_Log_Exception("Invalid regular expression '$regexp'"); + } + $this->_regexp = $regexp; + } + + /** + * Create a new instance of Zend_Log_Filter_Message + * + * @param array|Zend_Config $config + * @return Zend_Log_Filter_Message + */ + static public function factory($config) + { + $config = self::_parseConfig($config); + $config = array_merge(array( + 'regexp' => null + ), $config); + + return new self( + $config['regexp'] + ); + } + + /** + * Returns TRUE to accept the message, FALSE to block it. + * + * @param array $event event data + * @return boolean accepted? + */ + public function accept($event) + { + return preg_match($this->_regexp, $event['message']) > 0; + } +} diff --git a/library/vendor/Zend/Log/Filter/Priority.php b/library/vendor/Zend/Log/Filter/Priority.php new file mode 100644 index 0000000..f1dbd93 --- /dev/null +++ b/library/vendor/Zend/Log/Filter/Priority.php @@ -0,0 +1,99 @@ +<?php +/** + * Zend Framework + * + * LICENSE + * + * This source file is subject to the new BSD license that is bundled + * with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://framework.zend.com/license/new-bsd + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@zend.com so we can send you a copy immediately. + * + * @category Zend + * @package Zend_Log + * @subpackage Filter + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) + * @license http://framework.zend.com/license/new-bsd New BSD License + * @version $Id$ + */ + +/** Zend_Log_Filter_Abstract */ + +/** + * @category Zend + * @package Zend_Log + * @subpackage Filter + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) + * @license http://framework.zend.com/license/new-bsd New BSD License + * @version $Id$ + */ +class Zend_Log_Filter_Priority extends Zend_Log_Filter_Abstract +{ + /** + * @var integer + */ + protected $_priority; + + /** + * @var string + */ + protected $_operator; + + /** + * Filter logging by $priority. By default, it will accept any log + * event whose priority value is less than or equal to $priority. + * + * @param integer $priority Priority + * @param string $operator Comparison operator + * @return void + * @throws Zend_Log_Exception + */ + public function __construct($priority, $operator = null) + { + if (! is_int($priority)) { + throw new Zend_Log_Exception('Priority must be an integer'); + } + + $this->_priority = $priority; + $this->_operator = $operator === null ? '<=' : $operator; + } + + /** + * Create a new instance of Zend_Log_Filter_Priority + * + * @param array|Zend_Config $config + * @return Zend_Log_Filter_Priority + */ + static public function factory($config) + { + $config = self::_parseConfig($config); + $config = array_merge(array( + 'priority' => null, + 'operator' => null, + ), $config); + + // Add support for constants + if (!is_numeric($config['priority']) && isset($config['priority']) && defined($config['priority'])) { + $config['priority'] = constant($config['priority']); + } + + return new self( + (int) $config['priority'], + $config['operator'] + ); + } + + /** + * Returns TRUE to accept the message, FALSE to block it. + * + * @param array $event event data + * @return boolean accepted? + */ + public function accept($event) + { + return version_compare($event['priority'], $this->_priority, $this->_operator); + } +} diff --git a/library/vendor/Zend/Log/Filter/Suppress.php b/library/vendor/Zend/Log/Filter/Suppress.php new file mode 100644 index 0000000..3766077 --- /dev/null +++ b/library/vendor/Zend/Log/Filter/Suppress.php @@ -0,0 +1,76 @@ +<?php +/** + * Zend Framework + * + * LICENSE + * + * This source file is subject to the new BSD license that is bundled + * with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://framework.zend.com/license/new-bsd + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@zend.com so we can send you a copy immediately. + * + * @category Zend + * @package Zend_Log + * @subpackage Filter + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) + * @license http://framework.zend.com/license/new-bsd New BSD License + * @version $Id$ + */ + +/** Zend_Log_Filter_Interface */ + +/** + * @category Zend + * @package Zend_Log + * @subpackage Filter + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) + * @license http://framework.zend.com/license/new-bsd New BSD License + * @version $Id$ + */ +class Zend_Log_Filter_Suppress extends Zend_Log_Filter_Abstract +{ + /** + * @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; + } + + /** + * Create a new instance of Zend_Log_Filter_Suppress + * + * @param array|Zend_Config $config + * @return Zend_Log_Filter_Suppress + * @throws Zend_Log_Exception + */ + static public function factory($config) + { + return new self(); + } +} |