diff options
author | vipsoft <vipsoft@59fd770c-687e-43c8-a1e3-f5a4ff64c105> | 2010-01-29 12:02:30 +0300 |
---|---|---|
committer | vipsoft <vipsoft@59fd770c-687e-43c8-a1e3-f5a4ff64c105> | 2010-01-29 12:02:30 +0300 |
commit | 35522b4b45c78b1f3140cb82b20ac1039e111071 (patch) | |
tree | 61b8272e59891a9d5d175d8a883a978fd913daf0 /libs/Zend/Log/Writer | |
parent | f8b7c1788c8aaa0faca8ecbb2d47e976386ac751 (diff) |
update wrt Zend Framework 1.10.0; remove svn:eol-style property
Diffstat (limited to 'libs/Zend/Log/Writer')
-rw-r--r-- | libs/Zend/Log/Writer/Abstract.php | 34 | ||||
-rw-r--r-- | libs/Zend/Log/Writer/Db.php | 36 | ||||
-rw-r--r-- | libs/Zend/Log/Writer/Firebug.php | 20 | ||||
-rw-r--r-- | libs/Zend/Log/Writer/Mail.php | 20 | ||||
-rw-r--r-- | libs/Zend/Log/Writer/Mock.php | 22 | ||||
-rw-r--r-- | libs/Zend/Log/Writer/Null.php | 23 | ||||
-rw-r--r-- | libs/Zend/Log/Writer/Stream.php | 43 | ||||
-rw-r--r-- | libs/Zend/Log/Writer/Syslog.php | 18 | ||||
-rw-r--r-- | libs/Zend/Log/Writer/ZendMonitor.php | 111 |
9 files changed, 288 insertions, 39 deletions
diff --git a/libs/Zend/Log/Writer/Abstract.php b/libs/Zend/Log/Writer/Abstract.php index 3e3be2d6cd..979375a83f 100644 --- a/libs/Zend/Log/Writer/Abstract.php +++ b/libs/Zend/Log/Writer/Abstract.php @@ -15,9 +15,9 @@ * @category Zend * @package Zend_Log * @subpackage Writer - * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: Abstract.php 16219 2009-06-21 19:45:39Z thomas $ + * @version $Id: Abstract.php 20096 2010-01-06 02:05:09Z bkarwin $ */ /** Zend_Log_Filter_Priority */ @@ -27,11 +27,11 @@ require_once 'Zend/Log/Filter/Priority.php'; * @category Zend * @package Zend_Log * @subpackage Writer - * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: Abstract.php 16219 2009-06-21 19:45:39Z thomas $ + * @version $Id: Abstract.php 20096 2010-01-06 02:05:09Z bkarwin $ */ -abstract class Zend_Log_Writer_Abstract +abstract class Zend_Log_Writer_Abstract implements Zend_Log_FactoryInterface { /** * @var array of Zend_Log_Filter_Interface @@ -104,4 +104,26 @@ abstract class Zend_Log_Writer_Abstract */ abstract protected function _write($event); -}
\ No newline at end of file + /** + * 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)) { + require_once 'Zend/Log/Exception.php'; + throw new Zend_Log_Exception( + 'Configuration must be an array or instance of Zend_Config' + ); + } + + return $config; + } +} diff --git a/libs/Zend/Log/Writer/Db.php b/libs/Zend/Log/Writer/Db.php index 2130efe28e..63660aec6f 100644 --- a/libs/Zend/Log/Writer/Db.php +++ b/libs/Zend/Log/Writer/Db.php @@ -15,9 +15,9 @@ * @category Zend * @package Zend_Log * @subpackage Writer - * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: Db.php 16219 2009-06-21 19:45:39Z thomas $ + * @version $Id: Db.php 20096 2010-01-06 02:05:09Z bkarwin $ */ /** Zend_Log_Writer_Abstract */ @@ -27,9 +27,9 @@ require_once 'Zend/Log/Writer/Abstract.php'; * @category Zend * @package Zend_Log * @subpackage Writer - * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: Db.php 16219 2009-06-21 19:45:39Z thomas $ + * @version $Id: Db.php 20096 2010-01-06 02:05:09Z bkarwin $ */ class Zend_Log_Writer_Db extends Zend_Log_Writer_Abstract { @@ -67,6 +67,33 @@ class Zend_Log_Writer_Db extends Zend_Log_Writer_Abstract } /** + * Create a new instance of Zend_Log_Writer_Db + * + * @param array|Zend_Config $config + * @return Zend_Log_Writer_Db + * @throws Zend_Log_Exception + */ + static public function factory($config) + { + $config = self::_parseConfig($config); + $config = array_merge(array( + 'db' => null, + 'table' => null, + 'columnMap' => null, + ), $config); + + if (isset($config['columnmap'])) { + $config['columnMap'] = $config['columnmap']; + } + + return new self( + $config['db'], + $config['table'], + $config['columnMap'] + ); + } + + /** * Formatting is not possible on this writer */ public function setFormatter($formatter) @@ -109,5 +136,4 @@ class Zend_Log_Writer_Db extends Zend_Log_Writer_Abstract $this->_db->insert($this->_table, $dataToInsert); } - } diff --git a/libs/Zend/Log/Writer/Firebug.php b/libs/Zend/Log/Writer/Firebug.php index 54616d5009..5afd752401 100644 --- a/libs/Zend/Log/Writer/Firebug.php +++ b/libs/Zend/Log/Writer/Firebug.php @@ -15,9 +15,9 @@ * @category Zend * @package Zend_Log * @subpackage Writer - * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: Firebug.php 18951 2009-11-12 16:26:19Z alexander $ + * @version $Id: Firebug.php 20096 2010-01-06 02:05:09Z bkarwin $ */ /** Zend_Log */ @@ -38,7 +38,7 @@ require_once 'Zend/Wildfire/Plugin/FirePhp.php'; * @category Zend * @package Zend_Log * @subpackage Writer - * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ class Zend_Log_Writer_Firebug extends Zend_Log_Writer_Abstract @@ -74,12 +74,24 @@ class Zend_Log_Writer_Firebug extends Zend_Log_Writer_Abstract */ public function __construct() { - if (php_sapi_name()=='cli') { + if (php_sapi_name() == 'cli') { $this->setEnabled(false); } $this->_formatter = new Zend_Log_Formatter_Firebug(); } + + /** + * Create a new instance of Zend_Log_Writer_Firebug + * + * @param array|Zend_Config $config + * @return Zend_Log_Writer_Firebug + * @throws Zend_Log_Exception + */ + static public function factory($config) + { + return new self(); + } /** * Enable or disable the log writer. diff --git a/libs/Zend/Log/Writer/Mail.php b/libs/Zend/Log/Writer/Mail.php index 068bd33dc1..2d47670e1d 100644 --- a/libs/Zend/Log/Writer/Mail.php +++ b/libs/Zend/Log/Writer/Mail.php @@ -15,9 +15,9 @@ * @category Zend * @package Zend_Log * @subpackage Writer - * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: Mail.php 16219 2009-06-21 19:45:39Z thomas $ + * @version $Id: Mail.php 20096 2010-01-06 02:05:09Z bkarwin $ */ /** Zend_Log_Writer_Abstract */ @@ -39,9 +39,9 @@ require_once 'Zend/Log/Formatter/Simple.php'; * @category Zend * @package Zend_Log * @subpackage Writer - * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: Mail.php 16219 2009-06-21 19:45:39Z thomas $ + * @version $Id: Mail.php 20096 2010-01-06 02:05:09Z bkarwin $ */ class Zend_Log_Writer_Mail extends Zend_Log_Writer_Abstract { @@ -117,6 +117,18 @@ class Zend_Log_Writer_Mail extends Zend_Log_Writer_Abstract $this->_layout = $layout; $this->_formatter = new Zend_Log_Formatter_Simple(); } + + /** + * Create a new instance of Zend_Log_Writer_Mail + * + * @param array|Zend_Config $config + * @return Zend_Log_Writer_Mail + * @throws Zend_Log_Exception + */ + static public function factory($config) + { + throw new Zend_Exception('Zend_Log_Writer_Mail does not currently implement a factory'); + } /** * Places event line into array of lines to be used as message body. diff --git a/libs/Zend/Log/Writer/Mock.php b/libs/Zend/Log/Writer/Mock.php index 2a593c0d9e..f946219a9f 100644 --- a/libs/Zend/Log/Writer/Mock.php +++ b/libs/Zend/Log/Writer/Mock.php @@ -15,9 +15,9 @@ * @category Zend * @package Zend_Log * @subpackage Writer - * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: Mock.php 16971 2009-07-22 18:05:45Z mikaelkael $ + * @version $Id: Mock.php 20096 2010-01-06 02:05:09Z bkarwin $ */ /** Zend_Log_Writer_Abstract */ @@ -27,9 +27,9 @@ require_once 'Zend/Log/Writer/Abstract.php'; * @category Zend * @package Zend_Log * @subpackage Writer - * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: Mock.php 16971 2009-07-22 18:05:45Z mikaelkael $ + * @version $Id: Mock.php 20096 2010-01-06 02:05:09Z bkarwin $ */ class Zend_Log_Writer_Mock extends Zend_Log_Writer_Abstract { @@ -63,4 +63,16 @@ class Zend_Log_Writer_Mock extends Zend_Log_Writer_Abstract { $this->shutdown = true; } -}
\ No newline at end of file + + /** + * Create a new instance of Zend_Log_Writer_Mock + * + * @param array|Zend_Config $config + * @return Zend_Log_Writer_Mock + * @throws Zend_Log_Exception + */ + static public function factory($config) + { + return new self(); + } +} diff --git a/libs/Zend/Log/Writer/Null.php b/libs/Zend/Log/Writer/Null.php index de791d3a99..d86b69b583 100644 --- a/libs/Zend/Log/Writer/Null.php +++ b/libs/Zend/Log/Writer/Null.php @@ -15,9 +15,9 @@ * @category Zend * @package Zend_Log * @subpackage Writer - * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: Null.php 16219 2009-06-21 19:45:39Z thomas $ + * @version $Id: Null.php 20096 2010-01-06 02:05:09Z bkarwin $ */ /** Zend_Log_Writer_Abstract */ @@ -27,9 +27,9 @@ require_once 'Zend/Log/Writer/Abstract.php'; * @category Zend * @package Zend_Log * @subpackage Writer - * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: Null.php 16219 2009-06-21 19:45:39Z thomas $ + * @version $Id: Null.php 20096 2010-01-06 02:05:09Z bkarwin $ */ class Zend_Log_Writer_Null extends Zend_Log_Writer_Abstract { @@ -42,5 +42,16 @@ class Zend_Log_Writer_Null extends Zend_Log_Writer_Abstract protected function _write($event) { } - -}
\ No newline at end of file + + /** + * Create a new instance of Zend_Log_Writer_Null + * + * @param array|Zend_Config $config + * @return Zend_Log_Writer_Null + * @throws Zend_Log_Exception + */ + static public function factory($config) + { + return new self(); + } +} diff --git a/libs/Zend/Log/Writer/Stream.php b/libs/Zend/Log/Writer/Stream.php index 99b050ad6b..fdf924efdc 100644 --- a/libs/Zend/Log/Writer/Stream.php +++ b/libs/Zend/Log/Writer/Stream.php @@ -15,9 +15,9 @@ * @category Zend * @package Zend_Log * @subpackage Writer - * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: Stream.php 16219 2009-06-21 19:45:39Z thomas $ + * @version $Id: Stream.php 20096 2010-01-06 02:05:09Z bkarwin $ */ /** Zend_Log_Writer_Abstract */ @@ -30,9 +30,9 @@ require_once 'Zend/Log/Formatter/Simple.php'; * @category Zend * @package Zend_Log * @subpackage Writer - * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: Stream.php 16219 2009-06-21 19:45:39Z thomas $ + * @version $Id: Stream.php 20096 2010-01-06 02:05:09Z bkarwin $ */ class Zend_Log_Writer_Stream extends Zend_Log_Writer_Abstract { @@ -48,8 +48,13 @@ class Zend_Log_Writer_Stream extends Zend_Log_Writer_Abstract * @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') + public function __construct($streamOrUrl, $mode = NULL) { + // Setting the default + if ($mode === NULL) { + $mode = 'a'; + } + if (is_resource($streamOrUrl)) { if (get_resource_type($streamOrUrl) != 'stream') { require_once 'Zend/Log/Exception.php'; @@ -63,6 +68,10 @@ class Zend_Log_Writer_Stream extends Zend_Log_Writer_Abstract $this->_stream = $streamOrUrl; } else { + if (is_array($streamOrUrl) && isset($streamOrUrl['stream'])) { + $streamOrUrl = $streamOrUrl['stream']; + } + if (! $this->_stream = @fopen($streamOrUrl, $mode, false)) { require_once 'Zend/Log/Exception.php'; $msg = "\"$streamOrUrl\" cannot be opened with mode \"$mode\""; @@ -72,7 +81,30 @@ class Zend_Log_Writer_Stream extends Zend_Log_Writer_Abstract $this->_formatter = new Zend_Log_Formatter_Simple(); } + + /** + * Create a new instance of Zend_Log_Writer_Mock + * + * @param array|Zend_Config $config + * @return Zend_Log_Writer_Mock + * @throws Zend_Log_Exception + */ + static public function factory($config) + { + $config = self::_parseConfig($config); + $config = array_merge(array( + 'stream' => null, + 'mode' => null, + ), $config); + $streamOrUrl = isset($config['url']) ? $config['url'] : $config['stream']; + + return new self( + $streamOrUrl, + $config['mode'] + ); + } + /** * Close the stream resource. * @@ -100,5 +132,4 @@ class Zend_Log_Writer_Stream extends Zend_Log_Writer_Abstract throw new Zend_Log_Exception("Unable to write to stream"); } } - } diff --git a/libs/Zend/Log/Writer/Syslog.php b/libs/Zend/Log/Writer/Syslog.php index 3409ae56dc..96fbe56922 100644 --- a/libs/Zend/Log/Writer/Syslog.php +++ b/libs/Zend/Log/Writer/Syslog.php @@ -15,9 +15,9 @@ * @category Zend * @package Zend_Log * @subpackage Writer - * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: Syslog.php 16971 2009-07-22 18:05:45Z mikaelkael $ + * @version $Id: Syslog.php 20096 2010-01-06 02:05:09Z bkarwin $ */ /** Zend_Log_Writer_Abstract */ @@ -29,7 +29,7 @@ require_once 'Zend/Log/Writer/Abstract.php'; * @category Zend * @package Zend_Log * @subpackage Writer - * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ class Zend_Log_Writer_Syslog extends Zend_Log_Writer_Abstract @@ -95,6 +95,18 @@ class Zend_Log_Writer_Syslog extends Zend_Log_Writer_Abstract } $this->_initializeSyslog(); } + + /** + * Create a new instance of Zend_Log_Writer_Syslog + * + * @param array|Zend_Config $config + * @return Zend_Log_Writer_Syslog + * @throws Zend_Log_Exception + */ + static public function factory($config) + { + return new self(self::_parseConfig($config)); + } /** * Initialize syslog / set application name and facility diff --git a/libs/Zend/Log/Writer/ZendMonitor.php b/libs/Zend/Log/Writer/ZendMonitor.php new file mode 100644 index 0000000000..082f2a4f58 --- /dev/null +++ b/libs/Zend/Log/Writer/ZendMonitor.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-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @license http://framework.zend.com/license/new-bsd New BSD License + * @version $Id$ + */ + +/** Zend_Log_Writer_Abstract */ +require_once 'Zend/Log/Writer/Abstract.php'; + +/** + * @category Zend + * @package Zend_Log + * @subpackage Writer + * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @license http://framework.zend.com/license/new-bsd New BSD License + * @version $Id$ + */ +class Zend_Log_Writer_ZendMonitor extends Zend_Log_Writer_Abstract +{ + /** + * Is Zend Monitor enabled? + * @var bool + */ + protected $_isEnabled = true; + + /** + * @throws Zend_Log_Exception if Zend Monitor extension not present + */ + public function __construct() + { + if (!function_exists('monitor_custom_event')) { + $this->_isEnabled = false; + } + } + + /** + * Create a new instance of Zend_Log_Writer_ZendMonitor + * + * @param array|Zend_Config $config + * @return Zend_Log_Writer_Syslog + * @throws Zend_Log_Exception + */ + static public function factory($config) + { + return new self(); + } + + /** + * Is logging to this writer enabled? + * + * If the Zend Monitor extension is not enabled, this log writer will + * fail silently. You can query this method to determine if the log + * writer is enabled. + * + * @return bool + */ + public function isEnabled() + { + return $this->_isEnabled; + } + + /** + * Log a message to this writer. + * + * @param array $event log data event + * @return void + */ + public function write($event) + { + if (!$this->isEnabled()) { + return; + } + + parent::write($event); + } + + /** + * Write a message to the log. + * + * @param array $event log data event + * @return void + */ + protected function _write($event) + { + $priority = $event['priority']; + $message = $event['message']; + unset($event['priority'], $event['message']); + + if (!empty($event)) { + monitor_custom_event($priority, $message, $event); + } else { + monitor_custom_event($priority, $message); + } + } +} |