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:
authormattpiwik <matthieu.aubry@gmail.com>2007-07-24 16:57:04 +0400
committermattpiwik <matthieu.aubry@gmail.com>2007-07-24 16:57:04 +0400
commitb23ec243e5d16852836fb7086a9150417acb2183 (patch)
tree83a11cf9d9f02aaa41b0b7c93674eea72abe7912 /libs/Zend/Log
parent45f9ef24fb6d6d8b53a2a70d70c2b42d7d387104 (diff)
First code commit
(from subclipse) git-svn-id: http://dev.piwik.org/svn/trunk@10 59fd770c-687e-43c8-a1e3-f5a4ff64c105
Diffstat (limited to 'libs/Zend/Log')
-rwxr-xr-xlibs/Zend/Log/Exception.php33
-rwxr-xr-xlibs/Zend/Log/Filter/Interface.php41
-rwxr-xr-xlibs/Zend/Log/Filter/Message.php66
-rwxr-xr-xlibs/Zend/Log/Filter/Priority.php75
-rwxr-xr-xlibs/Zend/Log/Filter/Suppress.php66
-rwxr-xr-xlibs/Zend/Log/Formatter/Interface.php41
-rwxr-xr-xlibs/Zend/Log/Formatter/Simple.php75
-rwxr-xr-xlibs/Zend/Log/Formatter/Xml.php87
-rwxr-xr-xlibs/Zend/Log/Writer/Abstract.php109
-rwxr-xr-xlibs/Zend/Log/Writer/Db.php111
-rwxr-xr-xlibs/Zend/Log/Writer/Mock.php66
-rwxr-xr-xlibs/Zend/Log/Writer/Null.php46
-rwxr-xr-xlibs/Zend/Log/Writer/Stream.php100
13 files changed, 916 insertions, 0 deletions
diff --git a/libs/Zend/Log/Exception.php b/libs/Zend/Log/Exception.php
new file mode 100755
index 0000000000..b1018f8b34
--- /dev/null
+++ b/libs/Zend/Log/Exception.php
@@ -0,0 +1,33 @@
+<?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
+ * @copyright Copyright (c) 2005-2007 Zend Technologies USA Inc. (http://www.zend.com)
+ * @license http://framework.zend.com/license/new-bsd New BSD License
+ * @version $Id: Exception.php 4412 2007-04-06 21:17:32Z zendbot $
+ */
+
+/** Zend_Exception */
+require_once 'Zend/Exception.php';
+
+/**
+ * @category Zend
+ * @package Zend_Log
+ * @copyright Copyright (c) 2005-2007 Zend Technologies USA Inc. (http://www.zend.com)
+ * @license http://framework.zend.com/license/new-bsd New BSD License
+ * @version $Id: Exception.php 4412 2007-04-06 21:17:32Z zendbot $
+ */
+class Zend_Log_Exception extends Zend_Exception
+{}
diff --git a/libs/Zend/Log/Filter/Interface.php b/libs/Zend/Log/Filter/Interface.php
new file mode 100755
index 0000000000..c42808c826
--- /dev/null
+++ b/libs/Zend/Log/Filter/Interface.php
@@ -0,0 +1,41 @@
+<?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-2007 Zend Technologies USA Inc. (http://www.zend.com)
+ * @license http://framework.zend.com/license/new-bsd New BSD License
+ * @version $Id: Interface.php 4389 2007-04-06 15:17:41Z mike $
+ */
+
+/**
+ * @category Zend
+ * @package Zend_Log
+ * @subpackage Filter
+ * @copyright Copyright (c) 2005-2007 Zend Technologies USA Inc. (http://www.zend.com)
+ * @license http://framework.zend.com/license/new-bsd New BSD License
+ * @version $Id: Interface.php 4389 2007-04-06 15:17:41Z mike $
+ */
+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/libs/Zend/Log/Filter/Message.php b/libs/Zend/Log/Filter/Message.php
new file mode 100755
index 0000000000..4da81c4c10
--- /dev/null
+++ b/libs/Zend/Log/Filter/Message.php
@@ -0,0 +1,66 @@
+<?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-2007 Zend Technologies USA Inc. (http://www.zend.com)
+ * @license http://framework.zend.com/license/new-bsd New BSD License
+ * @version $Id: Message.php 4389 2007-04-06 15:17:41Z mike $
+ */
+
+/** Zend_Log_Filter_Interface */
+require_once 'Zend/Log/Filter/Interface.php';
+
+/**
+ * @category Zend
+ * @package Zend_Log
+ * @subpackage Filter
+ * @copyright Copyright (c) 2005-2007 Zend Technologies USA Inc. (http://www.zend.com)
+ * @license http://framework.zend.com/license/new-bsd New BSD License
+ * @version $Id: Message.php 4389 2007-04-06 15:17:41Z mike $
+ */
+class Zend_Log_Filter_Message implements Zend_Log_Filter_Interface
+{
+ /**
+ * @var string
+ */
+ protected $_regexp;
+
+ /**
+ * Filter out any log messages not matching $regexp.
+ *
+ * @param string $regexp Regular expression to test the log message
+ * @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;
+ }
+
+ /**
+ * 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/libs/Zend/Log/Filter/Priority.php b/libs/Zend/Log/Filter/Priority.php
new file mode 100755
index 0000000000..9c61ff28db
--- /dev/null
+++ b/libs/Zend/Log/Filter/Priority.php
@@ -0,0 +1,75 @@
+<?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-2007 Zend Technologies USA Inc. (http://www.zend.com)
+ * @license http://framework.zend.com/license/new-bsd New BSD License
+ * @version $Id: Priority.php 4474 2007-04-11 19:56:57Z mike $
+ */
+
+/** Zend_Log_Filter_Interface */
+require_once 'Zend/Log/Filter/Interface.php';
+
+/**
+ * @category Zend
+ * @package Zend_Log
+ * @subpackage Filter
+ * @copyright Copyright (c) 2005-2007 Zend Technologies USA Inc. (http://www.zend.com)
+ * @license http://framework.zend.com/license/new-bsd New BSD License
+ * @version $Id: Priority.php 4474 2007-04-11 19:56:57Z mike $
+ */
+class Zend_Log_Filter_Priority implements Zend_Log_Filter_Interface
+{
+ /**
+ * @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
+ * @throws Zend_Log_Exception
+ */
+ public function __construct($priority, $operator = '<=')
+ {
+ if (! is_integer($priority)) {
+ throw new Zend_Log_Exception('Priority must be an integer');
+ }
+
+ $this->_priority = $priority;
+ $this->_operator = $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/libs/Zend/Log/Filter/Suppress.php b/libs/Zend/Log/Filter/Suppress.php
new file mode 100755
index 0000000000..68a88311c7
--- /dev/null
+++ b/libs/Zend/Log/Filter/Suppress.php
@@ -0,0 +1,66 @@
+<?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-2007 Zend Technologies USA Inc. (http://www.zend.com)
+ * @license http://framework.zend.com/license/new-bsd New BSD License
+ * @version $Id: Suppress.php 4627 2007-04-28 01:29:42Z mike $
+ */
+
+/** Zend_Log_Filter_Interface */
+require_once 'Zend/Log/Filter/Interface.php';
+
+/**
+ * @category Zend
+ * @package Zend_Log
+ * @subpackage Filter
+ * @copyright Copyright (c) 2005-2007 Zend Technologies USA Inc. (http://www.zend.com)
+ * @license http://framework.zend.com/license/new-bsd New BSD License
+ * @version $Id: Suppress.php 4627 2007-04-28 01:29:42Z mike $
+ */
+class Zend_Log_Filter_Suppress implements Zend_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;
+ }
+
+}
diff --git a/libs/Zend/Log/Formatter/Interface.php b/libs/Zend/Log/Formatter/Interface.php
new file mode 100755
index 0000000000..9055156e14
--- /dev/null
+++ b/libs/Zend/Log/Formatter/Interface.php
@@ -0,0 +1,41 @@
+<?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 Formatter
+ * @copyright Copyright (c) 2005-2007 Zend Technologies USA Inc. (http://www.zend.com)
+ * @license http://framework.zend.com/license/new-bsd New BSD License
+ * @version $Id: Interface.php 4389 2007-04-06 15:17:41Z mike $
+ */
+
+/**
+ * @category Zend
+ * @package Zend_Log
+ * @subpackage Formatter
+ * @copyright Copyright (c) 2005-2007 Zend Technologies USA Inc. (http://www.zend.com)
+ * @license http://framework.zend.com/license/new-bsd New BSD License
+ * @version $Id: Interface.php 4389 2007-04-06 15:17:41Z mike $
+ */
+interface Zend_Log_Formatter_Interface
+{
+ /**
+ * Formats data into a single line to be written by the writer.
+ *
+ * @param array $event event data
+ * @return string formatted line to write to the log
+ */
+ public function format($event);
+
+}
diff --git a/libs/Zend/Log/Formatter/Simple.php b/libs/Zend/Log/Formatter/Simple.php
new file mode 100755
index 0000000000..4202ad9385
--- /dev/null
+++ b/libs/Zend/Log/Formatter/Simple.php
@@ -0,0 +1,75 @@
+<?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 Formatter
+ * @copyright Copyright (c) 2005-2007 Zend Technologies USA Inc. (http://www.zend.com)
+ * @license http://framework.zend.com/license/new-bsd New BSD License
+ * @version $Id: Simple.php 4389 2007-04-06 15:17:41Z mike $
+ */
+
+/** Zend_Log_Formatter_Interface */
+require_once 'Zend/Log/Formatter/Interface.php';
+
+/**
+ * @category Zend
+ * @package Zend_Log
+ * @subpackage Formatter
+ * @copyright Copyright (c) 2005-2007 Zend Technologies USA Inc. (http://www.zend.com)
+ * @license http://framework.zend.com/license/new-bsd New BSD License
+ * @version $Id: Simple.php 4389 2007-04-06 15:17:41Z mike $
+ */
+class Zend_Log_Formatter_Simple implements Zend_Log_Formatter_Interface
+{
+ /**
+ * @var string
+ */
+ protected $_format;
+
+ /**
+ * Class constructor
+ *
+ * @param null|string $format Format specifier for log messages
+ * @throws Zend_Log_Exception
+ */
+ public function __construct($format = null)
+ {
+ if ($format === null) {
+ $format = '%timestamp% %priorityName% (%priority%): %message%' . PHP_EOL;
+ }
+
+ if (! is_string($format)) {
+ throw new Zend_Log_Exception('Format must be a string');
+ }
+
+ $this->_format = $format;
+ }
+
+ /**
+ * Formats data into a single line to be written by the writer.
+ *
+ * @param array $event event data
+ * @return string formatted line to write to the log
+ */
+ public function format($event)
+ {
+ $output = $this->_format;
+ foreach ($event as $name => $value) {
+ $output = str_replace("%$name%", $value, $output);
+ }
+ return $output;
+ }
+
+}
diff --git a/libs/Zend/Log/Formatter/Xml.php b/libs/Zend/Log/Formatter/Xml.php
new file mode 100755
index 0000000000..1072fd4764
--- /dev/null
+++ b/libs/Zend/Log/Formatter/Xml.php
@@ -0,0 +1,87 @@
+<?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 Formatter
+ * @copyright Copyright (c) 2005-2007 Zend Technologies USA Inc. (http://www.zend.com)
+ * @license http://framework.zend.com/license/new-bsd New BSD License
+ * @version $Id: Xml.php 4389 2007-04-06 15:17:41Z mike $
+ */
+
+/** Zend_Log_Formatter_Interface */
+require_once 'Zend/Log/Formatter/Interface.php';
+
+/**
+ * @category Zend
+ * @package Zend_Log
+ * @subpackage Formatter
+ * @copyright Copyright (c) 2005-2007 Zend Technologies USA Inc. (http://www.zend.com)
+ * @license http://framework.zend.com/license/new-bsd New BSD License
+ * @version $Id: Xml.php 4389 2007-04-06 15:17:41Z mike $
+ */
+class Zend_Log_Formatter_Xml implements Zend_Log_Formatter_Interface
+{
+ /**
+ * @var Relates XML elements to log data field keys.
+ */
+ protected $_rootElement;
+
+ /**
+ * @var Relates XML elements to log data field keys.
+ */
+ protected $_elementMap;
+
+ /**
+ * Class constructor
+ *
+ * @param array $elementMap
+ */
+ public function __construct($rootElement = 'logEntry', $elementMap = null)
+ {
+ $this->_rootElement = $rootElement;
+ $this->_elementMap = $elementMap;
+ }
+
+ /**
+ * Formats data into a single line to be written by the writer.
+ *
+ * @param array $event event data
+ * @return string formatted line to write to the log
+ */
+ public function format($event)
+ {
+ if ($this->_elementMap === null) {
+ $dataToInsert = $event;
+ } else {
+ $dataToInsert = array();
+ foreach ($this->_elementMap as $elementName => $fieldKey) {
+ $dataToInsert[$elementName] = $event[$fieldKey];
+ }
+ }
+
+ $dom = new DOMDocument();
+ $elt = $dom->appendChild(new DOMElement($this->_rootElement));
+
+ foreach ($dataToInsert as $key => $value) {
+ $elt->appendChild(new DOMElement($key, $value));
+ }
+
+ $xml = $dom->saveXML();
+ $xml = preg_replace('/<\?xml version="1.0"( encoding="[^\"]*")?\?>\n/u', '', $xml);
+
+ return $xml . PHP_EOL;
+ }
+
+}
diff --git a/libs/Zend/Log/Writer/Abstract.php b/libs/Zend/Log/Writer/Abstract.php
new file mode 100755
index 0000000000..89966c0f7f
--- /dev/null
+++ b/libs/Zend/Log/Writer/Abstract.php
@@ -0,0 +1,109 @@
+<?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-2007 Zend Technologies USA Inc. (http://www.zend.com)
+ * @license http://framework.zend.com/license/new-bsd New BSD License
+ * @version $Id: Abstract.php 4560 2007-04-20 08:01:32Z mike $
+ */
+
+/** Zend_Log_Filter_Priority */
+require_once 'Zend/Log/Filter/Priority.php';
+
+/** Zend_Log_Exception */
+require_once 'Zend/Log/Exception.php';
+
+/**
+ * @category Zend
+ * @package Zend_Log
+ * @subpackage Writer
+ * @copyright Copyright (c) 2005-2007 Zend Technologies USA Inc. (http://www.zend.com)
+ * @license http://framework.zend.com/license/new-bsd New BSD License
+ * @version $Id: Abstract.php 4560 2007-04-20 08:01:32Z mike $
+ */
+abstract class Zend_Log_Writer_Abstract
+{
+ /**
+ * @var array of Zend_Log_Filter_Interface
+ */
+ protected $_filters = array();
+
+ /**
+ * Formats the log message before writing.
+ * @var Zend_Log_Formatter_Interface
+ */
+ protected $_formatter;
+
+ /**
+ * Add a filter specific to this writer.
+ *
+ * @param Zend_Log_Filter_Interface $filter
+ * @return void
+ */
+ public function addFilter($filter)
+ {
+ if (is_integer($filter)) {
+ $filter = new Zend_Log_Filter_Priority($filter);
+ }
+
+ $this->_filters[] = $filter;
+ }
+
+ /**
+ * Log a message to this writer.
+ *
+ * @param array $event log data event
+ * @return void
+ */
+ public function write($event)
+ {
+ foreach ($this->_filters as $filter) {
+ if (! $filter->accept($event)) {
+ return;
+ }
+ }
+
+ // exception occurs on error
+ $this->_write($event);
+ }
+
+ /**
+ * Set a new formatter for this writer
+ *
+ * @param Zend_Log_Formatter_Interface $formatter
+ * @return void
+ */
+ public function setFormatter($formatter) {
+ $this->_formatter = $formatter;
+ }
+
+ /**
+ * Perform shutdown activites such as closing open resources
+ *
+ * @return void
+ */
+ public function shutdown()
+ {}
+
+ /**
+ * Write a message to the log.
+ *
+ * @param array $event log data event
+ * @return void
+ */
+ abstract protected function _write($event);
+
+} \ No newline at end of file
diff --git a/libs/Zend/Log/Writer/Db.php b/libs/Zend/Log/Writer/Db.php
new file mode 100755
index 0000000000..540b98312d
--- /dev/null
+++ b/libs/Zend/Log/Writer/Db.php
@@ -0,0 +1,111 @@
+<?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-2007 Zend Technologies USA Inc. (http://www.zend.com)
+ * @license http://framework.zend.com/license/new-bsd New BSD License
+ * @version $Id: Db.php 5453 2007-06-26 17:03:01Z bkarwin $
+ */
+
+/** Zend_Log_Writer_Abstract */
+require_once 'Zend/Log/Writer/Abstract.php';
+
+/**
+ * @category Zend
+ * @package Zend_Log
+ * @subpackage Writer
+ * @copyright Copyright (c) 2005-2007 Zend Technologies USA Inc. (http://www.zend.com)
+ * @license http://framework.zend.com/license/new-bsd New BSD License
+ * @version $Id: Db.php 5453 2007-06-26 17:03:01Z bkarwin $
+ */
+class Zend_Log_Writer_Db extends Zend_Log_Writer_Abstract
+{
+ /**
+ * Database adapter instance
+ * @var Zend_Db_Adapter
+ */
+ private $_db;
+
+ /**
+ * Name of the log table in the database
+ * @var string
+ */
+ private $_table;
+
+ /**
+ * Relates database columns names to log data field keys.
+ *
+ * @var null|array
+ */
+ private $_columnMap;
+
+ /**
+ * Class constructor
+ *
+ * @param Zend_Db_Adapter $db Database adapter instance
+ * @param string $table Log table in database
+ * @param array $columnMap
+ */
+ public function __construct($db, $table, $columnMap = null)
+ {
+ $this->_db = $db;
+ $this->_table = $table;
+ $this->_columnMap = $columnMap;
+ }
+
+ /**
+ * Formatting is not possible on this writer
+ */
+ public function setFormatter($formatter)
+ {
+ throw new Zend_Log_Exception(get_class() . ' does not support formatting');
+ }
+
+ /**
+ * Remove reference to database adapter
+ *
+ * @return void
+ */
+ public function shutdown()
+ {
+ $this->_db = null;
+ }
+
+ /**
+ * Write a message to the log.
+ *
+ * @param array $event event data
+ * @return void
+ */
+ protected function _write($event)
+ {
+ if ($this->_db === null) {
+ throw new Zend_Log_Exception('Database adapter instance has been removed by shutdown');
+ }
+
+ if ($this->_columnMap === null) {
+ $dataToInsert = $event;
+ } else {
+ $dataToInsert = array();
+ foreach ($this->_columnMap as $columnName => $fieldKey) {
+ $dataToInsert[$columnName] = $event[$fieldKey];
+ }
+ }
+
+ $this->_db->insert($this->_table, $dataToInsert);
+ }
+
+}
diff --git a/libs/Zend/Log/Writer/Mock.php b/libs/Zend/Log/Writer/Mock.php
new file mode 100755
index 0000000000..8ed990692a
--- /dev/null
+++ b/libs/Zend/Log/Writer/Mock.php
@@ -0,0 +1,66 @@
+<?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-2007 Zend Technologies USA Inc. (http://www.zend.com)
+ * @license http://framework.zend.com/license/new-bsd New BSD License
+ * @version $Id: Null.php 3980 2007-03-15 21:38:38Z mike $
+ */
+
+/** Zend_Log_Writer_Abstract */
+require_once 'Zend/Log/Writer/Abstract.php';
+
+/**
+ * @category Zend
+ * @package Zend_Log
+ * @subpackage Writer
+ * @copyright Copyright (c) 2005-2007 Zend Technologies USA Inc. (http://www.zend.com)
+ * @license http://framework.zend.com/license/new-bsd New BSD License
+ * @version $Id: Null.php 3980 2007-03-15 21:38:38Z mike $
+ */
+class Zend_Log_Writer_Mock extends Zend_Log_Writer_Abstract
+{
+ /**
+ * array of log events
+ */
+ public $events = array();
+
+ /**
+ * shutdown called?
+ */
+ public $shutdown = false;
+
+ /**
+ * Write a message to the log.
+ *
+ * @param array $event event data
+ * @return void
+ */
+ public function _write($event)
+ {
+ $this->events[] = $event;
+ }
+
+ /**
+ * Record shutdown
+ *
+ * @return void
+ */
+ public function shutdown()
+ {
+ $this->shutdown = true;
+ }
+} \ No newline at end of file
diff --git a/libs/Zend/Log/Writer/Null.php b/libs/Zend/Log/Writer/Null.php
new file mode 100755
index 0000000000..319dbc5da7
--- /dev/null
+++ b/libs/Zend/Log/Writer/Null.php
@@ -0,0 +1,46 @@
+<?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-2007 Zend Technologies USA Inc. (http://www.zend.com)
+ * @license http://framework.zend.com/license/new-bsd New BSD License
+ * @version $Id: Null.php 4389 2007-04-06 15:17:41Z mike $
+ */
+
+/** Zend_Log_Writer_Abstract */
+require_once 'Zend/Log/Writer/Abstract.php';
+
+/**
+ * @category Zend
+ * @package Zend_Log
+ * @subpackage Writer
+ * @copyright Copyright (c) 2005-2007 Zend Technologies USA Inc. (http://www.zend.com)
+ * @license http://framework.zend.com/license/new-bsd New BSD License
+ * @version $Id: Null.php 4389 2007-04-06 15:17:41Z mike $
+ */
+class Zend_Log_Writer_Null extends Zend_Log_Writer_Abstract
+{
+ /**
+ * Write a message to the log.
+ *
+ * @param array $event event data
+ * @return void
+ */
+ protected function _write($event)
+ {
+ }
+
+} \ No newline at end of file
diff --git a/libs/Zend/Log/Writer/Stream.php b/libs/Zend/Log/Writer/Stream.php
new file mode 100755
index 0000000000..206a1251ab
--- /dev/null
+++ b/libs/Zend/Log/Writer/Stream.php
@@ -0,0 +1,100 @@
+<?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-2007 Zend Technologies USA Inc. (http://www.zend.com)
+ * @license http://framework.zend.com/license/new-bsd New BSD License
+ * @version $Id: Stream.php 4560 2007-04-20 08:01:32Z mike $
+ */
+
+/** Zend_Log_Writer_Abstract */
+require_once 'Zend/Log/Writer/Abstract.php';
+
+/** Zend_Log_Formatter_Simple */
+require_once 'Zend/Log/Formatter/Simple.php';
+
+/**
+ * @category Zend
+ * @package Zend_Log
+ * @subpackage Writer
+ * @copyright Copyright (c) 2005-2007 Zend Technologies USA Inc. (http://www.zend.com)
+ * @license http://framework.zend.com/license/new-bsd New BSD License
+ * @version $Id: Stream.php 4560 2007-04-20 08:01:32Z mike $
+ */
+class Zend_Log_Writer_Stream extends Zend_Log_Writer_Abstract
+{
+ /**
+ * Holds the PHP stream to log to.
+ * @var null|stream
+ */
+ protected $_stream = null;
+
+ /**
+ * Class Constructor
+ *
+ * @param streamOrUrl Stream or URL to open as a stream
+ * @param mode Mode, only applicable if a URL is given
+ */
+ public function __construct($streamOrUrl, $mode = 'a')
+ {
+ if (is_resource($streamOrUrl)) {
+ if (get_resource_type($streamOrUrl) != 'stream') {
+ throw new Zend_Log_Exception('Resource is not a stream');
+ }
+
+ if ($mode != 'a') {
+ throw new Zend_Log_Exception('Mode cannot be changed on existing streams');
+ }
+
+ $this->_stream = $streamOrUrl;
+ } else {
+ if (! $this->_stream = @fopen($streamOrUrl, $mode, false)) {
+ $msg = "\"$streamOrUrl\" cannot be opened with mode \"$mode\"";
+ throw new Zend_Log_Exception($msg);
+ }
+ }
+
+ $this->_formatter = new Zend_Log_Formatter_Simple();
+ }
+
+ /**
+ * Close the stream resource.
+ *
+ * @return void
+ */
+ public function shutdown()
+ {
+ if (is_resource($this->_stream)) {
+ fclose($this->_stream);
+ }
+ }
+
+ /**
+ * Write a message to the log.
+ *
+ * @param array $event event data
+ * @return void
+ */
+ protected function _write($event)
+ {
+ $line = $this->_formatter->format($event);
+
+ if (! @fwrite($this->_stream, $line)) {
+ throw new Zend_Log_Exception("Unable to write to stream");
+ }
+ }
+
+}