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:
authorrobocoder <anthon.pang@gmail.com>2011-01-10 21:50:50 +0300
committerrobocoder <anthon.pang@gmail.com>2011-01-10 21:50:50 +0300
commit7191afd6d6bb443708886bb013a4155271ce40d3 (patch)
tree3d1228f9d062d31354836f629c825ec7bedb88d3 /libs/Zend/Log/Writer
parentbae316c9500f56f78aa7b1c596d9ef38b8b50231 (diff)
fixes #1765 - updating to Zend Framework 1.11.2 with some modifications:
ZF-10888: loadClass() inconsistencies * Zend/Http/Client.php * Zend/Uri.php * Zend/Validate.php ZF-10890: include_path dependency and inconsistencies * Zend/Validate/Hostname.php refs #160 - added Zend_OpenId git-svn-id: http://dev.piwik.org/svn/trunk@3694 59fd770c-687e-43c8-a1e3-f5a4ff64c105
Diffstat (limited to 'libs/Zend/Log/Writer')
-rw-r--r--libs/Zend/Log/Writer/Abstract.php19
-rw-r--r--libs/Zend/Log/Writer/Db.php10
-rw-r--r--libs/Zend/Log/Writer/Firebug.php16
-rw-r--r--libs/Zend/Log/Writer/Mail.php139
-rw-r--r--libs/Zend/Log/Writer/Mock.php13
-rw-r--r--libs/Zend/Log/Writer/Null.php9
-rw-r--r--libs/Zend/Log/Writer/Stream.php35
-rw-r--r--libs/Zend/Log/Writer/Syslog.php30
-rw-r--r--libs/Zend/Log/Writer/ZendMonitor.php40
9 files changed, 241 insertions, 70 deletions
diff --git a/libs/Zend/Log/Writer/Abstract.php b/libs/Zend/Log/Writer/Abstract.php
index b3e244ba0e..11750458e5 100644
--- a/libs/Zend/Log/Writer/Abstract.php
+++ b/libs/Zend/Log/Writer/Abstract.php
@@ -17,7 +17,7 @@
* @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: Abstract.php 22632 2010-07-18 18:30:08Z ramon $
+ * @version $Id: Abstract.php 23576 2010-12-23 23:25:44Z ramon $
*/
/** Zend_Log_Filter_Priority */
@@ -29,7 +29,7 @@
* @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: Abstract.php 22632 2010-07-18 18:30:08Z ramon $
+ * @version $Id: Abstract.php 23576 2010-12-23 23:25:44Z ramon $
*/
abstract class Zend_Log_Writer_Abstract implements Zend_Log_FactoryInterface
{
@@ -40,6 +40,7 @@ abstract class Zend_Log_Writer_Abstract implements Zend_Log_FactoryInterface
/**
* Formats the log message before writing.
+ *
* @var Zend_Log_Formatter_Interface
*/
protected $_formatter;
@@ -48,11 +49,11 @@ abstract class Zend_Log_Writer_Abstract implements Zend_Log_FactoryInterface
* Add a filter specific to this writer.
*
* @param Zend_Log_Filter_Interface $filter
- * @return void
+ * @return Zend_Log_Writer_Abstract
*/
public function addFilter($filter)
{
- if (is_integer($filter)) {
+ if (is_int($filter)) {
$filter = new Zend_Log_Filter_Priority($filter);
}
@@ -63,12 +64,13 @@ abstract class Zend_Log_Writer_Abstract implements Zend_Log_FactoryInterface
}
$this->_filters[] = $filter;
+ return $this;
}
/**
* Log a message to this writer.
*
- * @param array $event log data event
+ * @param array $event log data event
* @return void
*/
public function write($event)
@@ -87,11 +89,12 @@ abstract class Zend_Log_Writer_Abstract implements Zend_Log_FactoryInterface
* Set a new formatter for this writer
*
* @param Zend_Log_Formatter_Interface $formatter
- * @return void
+ * @return Zend_Log_Writer_Abstract
*/
public function setFormatter(Zend_Log_Formatter_Interface $formatter)
{
$this->_formatter = $formatter;
+ return $this;
}
/**
@@ -126,8 +129,8 @@ abstract class Zend_Log_Writer_Abstract implements Zend_Log_FactoryInterface
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'
- );
+ '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 54634040b4..47217052d6 100644
--- a/libs/Zend/Log/Writer/Db.php
+++ b/libs/Zend/Log/Writer/Db.php
@@ -17,7 +17,7 @@
* @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: Db.php 22514 2010-07-01 14:11:18Z ramon $
+ * @version $Id: Db.php 23576 2010-12-23 23:25:44Z ramon $
*/
/** Zend_Log_Writer_Abstract */
@@ -29,18 +29,20 @@
* @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: Db.php 22514 2010-07-01 14:11:18Z ramon $
+ * @version $Id: Db.php 23576 2010-12-23 23:25:44Z ramon $
*/
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;
@@ -58,6 +60,7 @@ class Zend_Log_Writer_Db extends Zend_Log_Writer_Abstract
* @param Zend_Db_Adapter $db Database adapter instance
* @param string $table Log table in database
* @param array $columnMap
+ * @return void
*/
public function __construct($db, $table, $columnMap = null)
{
@@ -95,6 +98,9 @@ class Zend_Log_Writer_Db extends Zend_Log_Writer_Abstract
/**
* Formatting is not possible on this writer
+ *
+ * @return void
+ * @throws Zend_Log_Exception
*/
public function setFormatter(Zend_Log_Formatter_Interface $formatter)
{
diff --git a/libs/Zend/Log/Writer/Firebug.php b/libs/Zend/Log/Writer/Firebug.php
index 585f6a3dc1..94266506f1 100644
--- a/libs/Zend/Log/Writer/Firebug.php
+++ b/libs/Zend/Log/Writer/Firebug.php
@@ -17,7 +17,7 @@
* @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: Firebug.php 20096 2010-01-06 02:05:09Z bkarwin $
+ * @version $Id: Firebug.php 23576 2010-12-23 23:25:44Z ramon $
*/
/** Zend_Log */
@@ -43,9 +43,9 @@
*/
class Zend_Log_Writer_Firebug extends Zend_Log_Writer_Abstract
{
-
/**
* Maps logging priorities to logging display styles
+ *
* @var array
*/
protected $_priorityStyles = array(Zend_Log::EMERG => Zend_Wildfire_Plugin_FirePhp::ERROR,
@@ -59,18 +59,22 @@ class Zend_Log_Writer_Firebug extends Zend_Log_Writer_Abstract
/**
* The default logging style for un-mapped priorities
+ *
* @var string
*/
protected $_defaultPriorityStyle = Zend_Wildfire_Plugin_FirePhp::LOG;
/**
* Flag indicating whether the log writer is enabled
+ *
* @var boolean
*/
protected $_enabled = true;
/**
* Class constructor
+ *
+ * @return void
*/
public function __construct()
{
@@ -80,13 +84,12 @@ class Zend_Log_Writer_Firebug extends Zend_Log_Writer_Abstract
$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)
{
@@ -195,6 +198,7 @@ class Zend_Log_Writer_Firebug extends Zend_Log_Writer_Abstract
Zend_Wildfire_Plugin_FirePhp::getInstance()->send($message,
$label,
$type,
- array('traceOffset'=>6));
+ array('traceOffset'=>4,
+ 'fixZendLogOffsetIfApplicable'=>true));
}
}
diff --git a/libs/Zend/Log/Writer/Mail.php b/libs/Zend/Log/Writer/Mail.php
index 70f57b8616..2807a4ed52 100644
--- a/libs/Zend/Log/Writer/Mail.php
+++ b/libs/Zend/Log/Writer/Mail.php
@@ -17,7 +17,7 @@
* @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: Mail.php 20096 2010-01-06 02:05:09Z bkarwin $
+ * @version $Id: Mail.php 23576 2010-12-23 23:25:44Z ramon $
*/
/** Zend_Log_Writer_Abstract */
@@ -41,7 +41,7 @@
* @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: Mail.php 20096 2010-01-06 02:05:09Z bkarwin $
+ * @version $Id: Mail.php 23576 2010-12-23 23:25:44Z ramon $
*/
class Zend_Log_Writer_Mail extends Zend_Log_Writer_Abstract
{
@@ -101,6 +101,18 @@ class Zend_Log_Writer_Mail extends Zend_Log_Writer_Abstract
protected $_subjectPrependText;
/**
+ * MethodMap for Zend_Mail's headers
+ *
+ * @var array
+ */
+ protected static $_methodMapHeaders = array(
+ 'from' => 'setFrom',
+ 'to' => 'addTo',
+ 'cc' => 'addCc',
+ 'bcc' => 'addBcc',
+ );
+
+ /**
* Class constructor.
*
* Constructs the mail writer; requires a Zend_Mail instance, and takes an
@@ -113,21 +125,131 @@ class Zend_Log_Writer_Mail extends Zend_Log_Writer_Abstract
*/
public function __construct(Zend_Mail $mail, Zend_Layout $layout = null)
{
- $this->_mail = $mail;
- $this->_layout = $layout;
+ $this->_mail = $mail;
+ if (null !== $layout) {
+ $this->setLayout($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');
+ $config = self::_parseConfig($config);
+ $mail = self::_constructMailFromConfig($config);
+ $writer = new self($mail);
+
+ if (isset($config['layout']) || isset($config['layoutOptions'])) {
+ $writer->setLayout($config);
+ }
+ if (isset($config['layoutFormatter'])) {
+ $layoutFormatter = new $config['layoutFormatter'];
+ $writer->setLayoutFormatter($layoutFormatter);
+ }
+ if (isset($config['subjectPrependText'])) {
+ $writer->setSubjectPrependText($config['subjectPrependText']);
+ }
+
+ return $writer;
+ }
+
+ /**
+ * Set the layout
+ *
+ * @param Zend_Layout|array $layout
+ * @return Zend_Log_Writer_Mail
+ * @throws Zend_Log_Exception
+ */
+ public function setLayout($layout)
+ {
+ if (is_array($layout)) {
+ $layout = $this->_constructLayoutFromConfig($layout);
+ }
+
+ if (!$layout instanceof Zend_Layout) {
+ // require_once 'Zend/Log/Exception.php';
+ throw new Zend_Log_Exception('Mail must be an instance of Zend_Layout or an array');
+ }
+ $this->_layout = $layout;
+
+ return $this;
+ }
+
+ /**
+ * Construct a Zend_Mail instance based on a configuration array
+ *
+ * @param array $config
+ * @return Zend_Mail
+ * @throws Zend_Log_Exception
+ */
+ protected static function _constructMailFromConfig(array $config)
+ {
+ $mailClass = 'Zend_Mail';
+ if (isset($config['mail'])) {
+ $mailClass = $config['mail'];
+ }
+
+ if (!array_key_exists('charset', $config)) {
+ $config['charset'] = null;
+ }
+ $mail = new $mailClass($config['charset']);
+ if (!$mail instanceof Zend_Mail) {
+ throw new Zend_Log_Exception($mail . 'must extend Zend_Mail');
+ }
+
+ if (isset($config['subject'])) {
+ $mail->setSubject($config['subject']);
+ }
+
+ $headerAddresses = array_intersect_key($config, self::$_methodMapHeaders);
+ if (count($headerAddresses)) {
+ foreach ($headerAddresses as $header => $address) {
+ $method = self::$_methodMapHeaders[$header];
+ if (is_array($address) && isset($address['name'])
+ && !is_numeric($address['name'])
+ ) {
+ $params = array(
+ $address['email'],
+ $address['name']
+ );
+ } else if (is_array($address) && isset($address['email'])) {
+ $params = array($address['email']);
+ } else {
+ $params = array($address);
+ }
+ call_user_func_array(array($mail, $method), $params);
+ }
+ }
+
+ return $mail;
+ }
+
+ /**
+ * Construct a Zend_Layout instance based on a configuration array
+ *
+ * @param array $config
+ * @return Zend_Layout
+ * @throws Zend_Log_Exception
+ */
+ protected function _constructLayoutFromConfig(array $config)
+ {
+ $config = array_merge(array(
+ 'layout' => 'Zend_Layout',
+ 'layoutOptions' => null
+ ), $config);
+
+ $layoutClass = $config['layout'];
+ $layout = new $layoutClass($config['layoutOptions']);
+ if (!$layout instanceof Zend_Layout) {
+ throw new Zend_Log_Exception($layout . 'must extend Zend_Layout');
+ }
+
+ return $layout;
}
/**
@@ -211,6 +333,7 @@ class Zend_Log_Writer_Mail extends Zend_Log_Writer_Abstract
*
* @param string $subject Subject prepend text.
* @return Zend_Log_Writer_Mail
+ * @throws Zend_Log_Exception
*/
public function setSubjectPrependText($subject)
{
diff --git a/libs/Zend/Log/Writer/Mock.php b/libs/Zend/Log/Writer/Mock.php
index 1e14a2f00e..29984292b6 100644
--- a/libs/Zend/Log/Writer/Mock.php
+++ b/libs/Zend/Log/Writer/Mock.php
@@ -17,7 +17,7 @@
* @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: Mock.php 20096 2010-01-06 02:05:09Z bkarwin $
+ * @version $Id: Mock.php 23576 2010-12-23 23:25:44Z ramon $
*/
/** Zend_Log_Writer_Abstract */
@@ -29,17 +29,21 @@
* @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: Mock.php 20096 2010-01-06 02:05:09Z bkarwin $
+ * @version $Id: Mock.php 23576 2010-12-23 23:25:44Z ramon $
*/
class Zend_Log_Writer_Mock extends Zend_Log_Writer_Abstract
{
/**
* array of log events
+ *
+ * @var array
*/
public $events = array();
/**
* shutdown called?
+ *
+ * @var boolean
*/
public $shutdown = false;
@@ -66,12 +70,11 @@ class Zend_Log_Writer_Mock extends Zend_Log_Writer_Abstract
/**
* 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)
+ 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 f281883fbb..9d80cf1552 100644
--- a/libs/Zend/Log/Writer/Null.php
+++ b/libs/Zend/Log/Writer/Null.php
@@ -17,7 +17,7 @@
* @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: Null.php 20096 2010-01-06 02:05:09Z bkarwin $
+ * @version $Id: Null.php 23576 2010-12-23 23:25:44Z ramon $
*/
/** Zend_Log_Writer_Abstract */
@@ -29,7 +29,7 @@
* @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: Null.php 20096 2010-01-06 02:05:09Z bkarwin $
+ * @version $Id: Null.php 23576 2010-12-23 23:25:44Z ramon $
*/
class Zend_Log_Writer_Null extends Zend_Log_Writer_Abstract
{
@@ -42,13 +42,12 @@ class Zend_Log_Writer_Null extends Zend_Log_Writer_Abstract
protected function _write($event)
{
}
-
+
/**
* 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)
{
diff --git a/libs/Zend/Log/Writer/Stream.php b/libs/Zend/Log/Writer/Stream.php
index b722dbb4bd..25d6d75892 100644
--- a/libs/Zend/Log/Writer/Stream.php
+++ b/libs/Zend/Log/Writer/Stream.php
@@ -17,7 +17,7 @@
* @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: Stream.php 20096 2010-01-06 02:05:09Z bkarwin $
+ * @version $Id: Stream.php 23584 2010-12-28 19:51:49Z matthew $
*/
/** Zend_Log_Writer_Abstract */
@@ -32,12 +32,13 @@
* @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: Stream.php 20096 2010-01-06 02:05:09Z bkarwin $
+ * @version $Id: Stream.php 23584 2010-12-28 19:51:49Z matthew $
*/
class Zend_Log_Writer_Stream extends Zend_Log_Writer_Abstract
{
/**
* Holds the PHP stream to log to.
+ *
* @var null|stream
*/
protected $_stream = null;
@@ -45,13 +46,15 @@ class Zend_Log_Writer_Stream extends Zend_Log_Writer_Abstract
/**
* Class Constructor
*
- * @param streamOrUrl Stream or URL to open as a stream
- * @param mode Mode, only applicable if a URL is given
+ * @param array|string|resource $streamOrUrl Stream or URL to open as a stream
+ * @param string|null $mode Mode, only applicable if a URL is given
+ * @return void
+ * @throws Zend_Log_Exception
*/
- public function __construct($streamOrUrl, $mode = NULL)
+ public function __construct($streamOrUrl, $mode = null)
{
// Setting the default
- if ($mode === NULL) {
+ if (null === $mode) {
$mode = 'a';
}
@@ -81,30 +84,29 @@ 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
- *
+ * Create a new instance of Zend_Log_Writer_Stream
+ *
* @param array|Zend_Config $config
- * @return Zend_Log_Writer_Mock
- * @throws Zend_Log_Exception
+ * @return Zend_Log_Writer_Stream
*/
static public function factory($config)
{
$config = self::_parseConfig($config);
$config = array_merge(array(
- 'stream' => null,
+ 'stream' => null,
'mode' => null,
), $config);
- $streamOrUrl = isset($config['url']) ? $config['url'] : $config['stream'];
-
+ $streamOrUrl = isset($config['url']) ? $config['url'] : $config['stream'];
+
return new self(
- $streamOrUrl,
+ $streamOrUrl,
$config['mode']
);
}
-
+
/**
* Close the stream resource.
*
@@ -122,6 +124,7 @@ class Zend_Log_Writer_Stream extends Zend_Log_Writer_Abstract
*
* @param array $event event data
* @return void
+ * @throws Zend_Log_Exception
*/
protected function _write($event)
{
diff --git a/libs/Zend/Log/Writer/Syslog.php b/libs/Zend/Log/Writer/Syslog.php
index 722744271b..0ac5a5690a 100644
--- a/libs/Zend/Log/Writer/Syslog.php
+++ b/libs/Zend/Log/Writer/Syslog.php
@@ -17,9 +17,12 @@
* @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: Syslog.php 22632 2010-07-18 18:30:08Z ramon $
+ * @version $Id: Syslog.php 23576 2010-12-23 23:25:44Z ramon $
*/
+/** Zend_Log */
+// require_once 'Zend/Log.php';
+
/** Zend_Log_Writer_Abstract */
// require_once 'Zend/Log/Writer/Abstract.php';
@@ -36,6 +39,7 @@ class Zend_Log_Writer_Syslog extends Zend_Log_Writer_Abstract
{
/**
* Maps Zend_Log priorities to PHP's syslog priorities
+ *
* @var array
*/
protected $_priorities = array(
@@ -51,36 +55,41 @@ class Zend_Log_Writer_Syslog extends Zend_Log_Writer_Abstract
/**
* The default log priority - for unmapped custom priorities
+ *
* @var string
*/
protected $_defaultPriority = LOG_NOTICE;
/**
* Last application name set by a syslog-writer instance
+ *
* @var string
*/
protected static $_lastApplication;
/**
* Last facility name set by a syslog-writer instance
+ *
* @var string
*/
protected static $_lastFacility;
/**
* Application name used by this syslog-writer instance
+ *
* @var string
*/
protected $_application = 'Zend_Log';
/**
* Facility used by this syslog-writer instance
+ *
* @var int
*/
protected $_facility = LOG_USER;
/**
- * _validFacilities
+ * Types of program available to logging of message
*
* @var array
*/
@@ -89,7 +98,7 @@ class Zend_Log_Writer_Syslog extends Zend_Log_Writer_Abstract
/**
* Class constructor
*
- * @param array $options Array of options; may include "application" and "facility" keys
+ * @param array $params Array of options; may include "application" and "facility" keys
* @return void
*/
public function __construct(array $params = array())
@@ -100,7 +109,7 @@ class Zend_Log_Writer_Syslog extends Zend_Log_Writer_Abstract
$runInitializeSyslog = true;
if (isset($params['facility'])) {
- $this->_facility = $this->setFacility($params['facility']);
+ $this->setFacility($params['facility']);
$runInitializeSyslog = false;
}
@@ -114,7 +123,6 @@ class Zend_Log_Writer_Syslog extends Zend_Log_Writer_Abstract
*
* @param array|Zend_Config $config
* @return Zend_Log_Writer_Syslog
- * @throws Zend_Log_Exception
*/
static public function factory($config)
{
@@ -173,13 +181,13 @@ class Zend_Log_Writer_Syslog extends Zend_Log_Writer_Abstract
* Set syslog facility
*
* @param int $facility Syslog facility
- * @return void
+ * @return Zend_Log_Writer_Syslog
* @throws Zend_Log_Exception for invalid log facility
*/
public function setFacility($facility)
{
if ($this->_facility === $facility) {
- return;
+ return $this;
}
if (!count($this->_validFacilities)) {
@@ -200,21 +208,23 @@ class Zend_Log_Writer_Syslog extends Zend_Log_Writer_Abstract
$this->_facility = $facility;
$this->_initializeSyslog();
+ return $this;
}
/**
* Set application name
*
* @param string $application Application name
- * @return void
+ * @return Zend_Log_Writer_Syslog
*/
public function setApplicationName($application)
{
if ($this->_application === $application) {
- return;
+ return $this;
}
$this->_application = $application;
$this->_initializeSyslog();
+ return $this;
}
/**
@@ -230,7 +240,7 @@ class Zend_Log_Writer_Syslog extends Zend_Log_Writer_Abstract
/**
* Write a message to syslog.
*
- * @param array $event event data
+ * @param array $event event data
* @return void
*/
protected function _write($event)
diff --git a/libs/Zend/Log/Writer/ZendMonitor.php b/libs/Zend/Log/Writer/ZendMonitor.php
index a6c1843779..1dbf677940 100644
--- a/libs/Zend/Log/Writer/ZendMonitor.php
+++ b/libs/Zend/Log/Writer/ZendMonitor.php
@@ -17,7 +17,7 @@
* @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: ZendMonitor.php 22533 2010-07-07 02:38:14Z ramon $
+ * @version $Id: ZendMonitor.php 23576 2010-12-23 23:25:44Z ramon $
*/
/** Zend_Log_Writer_Abstract */
@@ -29,32 +29,42 @@
* @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: ZendMonitor.php 22533 2010-07-07 02:38:14Z ramon $
+ * @version $Id: ZendMonitor.php 23576 2010-12-23 23:25:44Z ramon $
*/
class Zend_Log_Writer_ZendMonitor extends Zend_Log_Writer_Abstract
{
/**
* Is Zend Monitor enabled?
- * @var bool
+ *
+ * @var boolean
*/
protected $_isEnabled = true;
/**
- * @throws Zend_Log_Exception if Zend Monitor extension not present
+ * Is this for a Zend Server intance?
+ *
+ * @var boolean
+ */
+ protected $_isZendServer = false;
+
+ /**
+ * @return void
*/
public function __construct()
{
if (!function_exists('monitor_custom_event')) {
$this->_isEnabled = false;
}
+ if (function_exists('zend_monitor_custom_event')) {
+ $this->_isZendServer = true;
+ }
}
/**
* Create a new instance of Zend_Log_Writer_ZendMonitor
*
* @param array|Zend_Config $config
- * @return Zend_Log_Writer_Syslog
- * @throws Zend_Log_Exception
+ * @return Zend_Log_Writer_ZendMonitor
*/
static public function factory($config)
{
@@ -68,7 +78,7 @@ class Zend_Log_Writer_ZendMonitor extends Zend_Log_Writer_Abstract
* fail silently. You can query this method to determine if the log
* writer is enabled.
*
- * @return bool
+ * @return boolean
*/
public function isEnabled()
{
@@ -78,7 +88,7 @@ class Zend_Log_Writer_ZendMonitor extends Zend_Log_Writer_Abstract
/**
* Log a message to this writer.
*
- * @param array $event log data event
+ * @param array $event log data event
* @return void
*/
public function write($event)
@@ -93,7 +103,7 @@ class Zend_Log_Writer_ZendMonitor extends Zend_Log_Writer_Abstract
/**
* Write a message to the log.
*
- * @param array $event log data event
+ * @param array $event log data event
* @return void
*/
protected function _write($event)
@@ -103,7 +113,17 @@ class Zend_Log_Writer_ZendMonitor extends Zend_Log_Writer_Abstract
unset($event['priority'], $event['message']);
if (!empty($event)) {
- monitor_custom_event($priority, $message, false, $event);
+ if ($this->_isZendServer) {
+ // On Zend Server; third argument should be the event
+ zend_monitor_custom_event($priority, $message, $event);
+ } else {
+ // On Zend Platform; third argument is severity -- either
+ // 0 or 1 -- and fourth is optional (event)
+ // Severity is either 0 (normal) or 1 (severe); classifying
+ // notice, info, and debug as "normal", and all others as
+ // "severe"
+ monitor_custom_event($priority, $message, ($priority > 4) ? 0 : 1, $event);
+ }
} else {
monitor_custom_event($priority, $message);
}