Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/matomo-org/matomo.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'libs/Zend/Log.php')
-rw-r--r--libs/Zend/Log.php237
1 files changed, 17 insertions, 220 deletions
diff --git a/libs/Zend/Log.php b/libs/Zend/Log.php
index 471c0e3cf4..04b7ebb85a 100644
--- a/libs/Zend/Log.php
+++ b/libs/Zend/Log.php
@@ -14,17 +14,17 @@
*
* @category Zend
* @package Zend_Log
- * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
+ * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
- * @version $Id: Log.php 20893 2010-02-03 22:59:25Z yoshida@zend.co.jp $
+ * @version $Id: Log.php 16207 2009-06-21 19:17:51Z thomas $
*/
/**
* @category Zend
* @package Zend_Log
- * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
+ * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
- * @version $Id: Log.php 20893 2010-02-03 22:59:25Z yoshida@zend.co.jp $
+ * @version $Id: Log.php 16207 2009-06-21 19:17:51Z thomas $
*/
class Zend_Log
{
@@ -59,19 +59,6 @@ class Zend_Log
protected $_extras = array();
/**
- *
- * @var string
- */
- protected $_defaultWriterNamespace = 'Zend_Log_Writer';
-
- /**
- *
- * @var string
- */
- protected $_defaultFilterNamespace = 'Zend_Log_Filter';
-
-
- /**
* Class constructor. Create a new logger
*
* @param Zend_Log_Writer_Abstract|null $writer default writer
@@ -87,146 +74,6 @@ class Zend_Log
}
/**
- * Factory to construct the logger and one or more writers
- * based on the configuration array
- *
- * @param array|Zend_Config Array or instance of Zend_Config
- * @return Zend_Log
- */
- static public function factory($config = array())
- {
- if ($config instanceof Zend_Config) {
- $config = $config->toArray();
- }
-
- if (!is_array($config) || empty($config)) {
- /** @see Zend_Log_Exception */
- // require_once 'Zend/Log/Exception.php';
- throw new Zend_Log_Exception('Configuration must be an array or instance of Zend_Config');
- }
-
- $log = new Zend_Log;
-
- if (!is_array(current($config))) {
- $log->addWriter(current($config));
- } else {
- foreach($config as $writer) {
- $log->addWriter($writer);
- }
- }
-
- return $log;
- }
-
-
- /**
- * Construct a writer object based on a configuration array
- *
- * @param array $spec config array with writer spec
- * @return Zend_Log_Writer_Abstract
- */
- protected function _constructWriterFromConfig($config)
- {
- $writer = $this->_constructFromConfig('writer', $config, $this->_defaultWriterNamespace);
-
- if (!$writer instanceof Zend_Log_Writer_Abstract) {
- /** @see Zend_Log_Exception */
- // require_once 'Zend/Log/Exception.php';
- throw new Zend_Log_Exception("{$writerName} does not extend Zend_Log_Writer_Abstract!");
- }
-
- if (isset($config['filterName'])) {
- $filter = $this->_constructFilterFromConfig($config);
- $writer->addFilter($filter);
- }
-
- return $writer;
- }
-
- /**
- * Construct filter object from configuration array or Zend_Config object
- *
- * @param array|Zend_Config $config Zend_Config or Array
- * @return Zend_Log_Filter_Interface
- */
- protected function _constructFilterFromConfig($config)
- {
- $filter = $this->_constructFromConfig('filter', $config, $this->_defaultFilterNamespace);
-
- if (!$filter instanceof Zend_Log_Filter_Interface) {
- /** @see Zend_Log_Exception */
- // require_once 'Zend/Log/Exception.php';
- throw new Zend_Log_Exception("{$filterName} does not implement Zend_Log_Filter_Interface");
- }
-
- return $filter;
- }
-
- /**
- * Construct a filter or writer from config
- *
- * @param string $type 'writer' of 'filter'
- * @param mixed $config Zend_Config or Array
- * @param string $namespace
- * @return object
- */
- protected function _constructFromConfig($type, $config, $namespace)
- {
- if ($config instanceof Zend_Config) {
- $config = $config->toArray();
- }
-
- if (!is_array($config) || empty($config)) {
- // require_once 'Zend/Log/Exception.php';
- throw new Zend_Log_Exception(
- 'Configuration must be an array or instance of Zend_Config'
- );
- }
-
- $params = isset($config[ $type .'Params' ]) ? $config[ $type .'Params' ] : array();
- $className = $this->getClassName($config, $type, $namespace);
- // if (!class_exists($className)) {
- // require_once 'Zend/Loader.php';
- // Zend_Loader::loadClass($className);
- // }
-
- $reflection = new ReflectionClass($className);
- if (!$reflection->implementsInterface('Zend_Log_FactoryInterface')) {
- // require_once 'Zend/Log/Exception.php';
- throw new Zend_Log_Exception(
- 'Driver does not implement Zend_Log_FactoryInterface and can not be constructed from config.'
- );
- }
-
- return call_user_func(array($className, 'factory'), $params);
- }
-
- /**
- * Get the writer or filter full classname
- *
- * @param array $config
- * @param string $type filter|writer
- * @param string $defaultNamespace
- * @return string full classname
- */
- protected function getClassName($config, $type, $defaultNamespace)
- {
- if (!isset($config[ $type . 'Name' ])) {
- // require_once 'Zend/Log/Exception.php';
- throw new Zend_Log_Exception("Specify {$type}Name in the configuration array");
- }
- $className = $config[ $type . 'Name' ];
-
- $namespace = $defaultNamespace;
- if (isset($config[ $type . 'Namespace' ])) {
- $namespace = $config[ $type . 'Namespace' ];
- }
-
- $fullClassName = $namespace . '_' . $className;
- return $fullClassName;
- }
-
- /**
* Class destructor. Shutdown log writers
*
* @return void
@@ -253,24 +100,10 @@ class Zend_Log
{
$priority = strtoupper($method);
if (($priority = array_search($priority, $this->_priorities)) !== false) {
- switch (count($params)) {
- case 0:
- /** @see Zend_Log_Exception */
- // require_once 'Zend/Log/Exception.php';
- throw new Zend_Log_Exception('Missing log message');
- case 1:
- $message = array_shift($params);
- $extras = null;
- break;
- default:
- $message = array_shift($params);
- $extras = array_shift($params);
- break;
- }
- $this->log($message, $priority, $extras);
+ $this->log(array_shift($params), $priority);
} else {
/** @see Zend_Log_Exception */
- // require_once 'Zend/Log/Exception.php';
+ require_once 'Zend/Log/Exception.php';
throw new Zend_Log_Exception('Bad log priority');
}
}
@@ -280,22 +113,21 @@ class Zend_Log
*
* @param string $message Message to log
* @param integer $priority Priority of message
- * @param mixed $extras Extra information to log in event
* @return void
* @throws Zend_Log_Exception
*/
- public function log($message, $priority, $extras = null)
+ public function log($message, $priority)
{
// sanity checks
if (empty($this->_writers)) {
/** @see Zend_Log_Exception */
- // require_once 'Zend/Log/Exception.php';
+ require_once 'Zend/Log/Exception.php';
throw new Zend_Log_Exception('No writers were added');
}
if (! isset($this->_priorities[$priority])) {
/** @see Zend_Log_Exception */
- // require_once 'Zend/Log/Exception.php';
+ require_once 'Zend/Log/Exception.php';
throw new Zend_Log_Exception('Bad log priority');
}
@@ -306,25 +138,6 @@ class Zend_Log
'priorityName' => $this->_priorities[$priority]),
$this->_extras);
- // Check to see if any extra information was passed
- if (!empty($extras)) {
- $info = array();
- if (is_array($extras)) {
- foreach ($extras as $key => $value) {
- if (is_string($key)) {
- $event[$key] = $value;
- } else {
- $info[] = $value;
- }
- }
- } else {
- $info = $extras;
- }
- if (!empty($info)) {
- $event['info'] = $info;
- }
- }
-
// abort if rejected by the global filters
foreach ($this->_filters as $filter) {
if (! $filter->accept($event)) {
@@ -353,7 +166,7 @@ class Zend_Log
if (isset($this->_priorities[$priority])
|| array_search($name, $this->_priorities)) {
/** @see Zend_Log_Exception */
- // require_once 'Zend/Log/Exception.php';
+ require_once 'Zend/Log/Exception.php';
throw new Zend_Log_Exception('Existing priorities cannot be overwritten');
}
@@ -371,16 +184,12 @@ class Zend_Log
public function addFilter($filter)
{
if (is_integer($filter)) {
- /** @see Zend_Log_Filter_Priority */
- // require_once 'Zend/Log/Filter/Priority.php';
+ /** @see Zend_Log_Filter_Priority */
+ require_once 'Zend/Log/Filter/Priority.php';
$filter = new Zend_Log_Filter_Priority($filter);
-
- } elseif ($filter instanceof Zend_Config || is_array($filter)) {
- $filter = $this->_constructFilterFromConfig($filter);
-
- } elseif(! $filter instanceof Zend_Log_Filter_Interface) {
+ } elseif(!is_object($filter) || ! $filter instanceof Zend_Log_Filter_Interface) {
/** @see Zend_Log_Exception */
- // require_once 'Zend/Log/Exception.php';
+ require_once 'Zend/Log/Exception.php';
throw new Zend_Log_Exception('Invalid filter provided');
}
@@ -391,24 +200,11 @@ class Zend_Log
* Add a writer. A writer is responsible for taking a log
* message and writing it out to storage.
*
- * @param mixed $writer Zend_Log_Writer_Abstract or Config array
+ * @param Zend_Log_Writer_Abstract $writer
* @return void
*/
- public function addWriter($writer)
+ public function addWriter(Zend_Log_Writer_Abstract $writer)
{
- if (is_array($writer) || $writer instanceof Zend_Config) {
- $writer = $this->_constructWriterFromConfig($writer);
- }
-
- if (!$writer instanceof Zend_Log_Writer_Abstract) {
- /** @see Zend_Log_Exception */
- // require_once 'Zend/Log/Exception.php';
- throw new Zend_Log_Exception(
- 'Writer must be an instance of Zend_Log_Writer_Abstract'
- . ' or you should pass a configuration array'
- );
- }
-
$this->_writers[] = $writer;
}
@@ -422,4 +218,5 @@ class Zend_Log
public function setEventItem($name, $value) {
$this->_extras = array_merge($this->_extras, array($name => $value));
}
+
}