import v1.1.0_beta1 | 2009-08-21

This commit is contained in:
2019-07-17 22:16:19 +02:00
parent 2c1152f0d3
commit 8dee6b1a10
2306 changed files with 251360 additions and 23428 deletions

View File

@ -17,7 +17,7 @@
* @subpackage Filter
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: Message.php 8064 2008-02-16 10:58:39Z thomas $
* @version $Id: Message.php 14132 2009-02-21 20:23:00Z shahar $
*/
/** Zend_Log_Filter_Interface */
@ -29,7 +29,7 @@ require_once 'Zend/Log/Filter/Interface.php';
* @subpackage Filter
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: Message.php 8064 2008-02-16 10:58:39Z thomas $
* @version $Id: Message.php 14132 2009-02-21 20:23:00Z shahar $
*/
class Zend_Log_Filter_Message implements Zend_Log_Filter_Interface
{
@ -47,6 +47,7 @@ class Zend_Log_Filter_Message implements Zend_Log_Filter_Interface
public function __construct($regexp)
{
if (@preg_match($regexp, '') === false) {
require_once 'Zend/Log/Exception.php';
throw new Zend_Log_Exception("Invalid regular expression '$regexp'");
}
$this->_regexp = $regexp;

View File

@ -17,7 +17,7 @@
* @subpackage Filter
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: Priority.php 8064 2008-02-16 10:58:39Z thomas $
* @version $Id: Priority.php 14132 2009-02-21 20:23:00Z shahar $
*/
/** Zend_Log_Filter_Interface */
@ -29,7 +29,7 @@ require_once 'Zend/Log/Filter/Interface.php';
* @subpackage Filter
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: Priority.php 8064 2008-02-16 10:58:39Z thomas $
* @version $Id: Priority.php 14132 2009-02-21 20:23:00Z shahar $
*/
class Zend_Log_Filter_Priority implements Zend_Log_Filter_Interface
{
@ -54,6 +54,7 @@ class Zend_Log_Filter_Priority implements Zend_Log_Filter_Interface
public function __construct($priority, $operator = '<=')
{
if (! is_integer($priority)) {
require_once 'Zend/Log/Exception.php';
throw new Zend_Log_Exception('Priority must be an integer');
}

View File

@ -0,0 +1,49 @@
<?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-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
/** Zend_Log_Formatter_Interface */
require_once 'Zend/Log/Formatter/Interface.php';
/**
* @category Zend
* @package Zend_Log
* @subpackage Formatter
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_Log_Formatter_Firebug implements Zend_Log_Formatter_Interface
{
/**
* This method formats the event for the firebug writer.
*
* The default is to just send the message parameter, but through
* extension of this class and calling the
* {@see Zend_Log_Writer_Firebug::setFormatter()} method you can
* pass as much of the event data as you are interested in.
*
* @param array $event event data
* @return mixed event message
*/
public function format($event)
{
return $event['message'];
}
}

View File

@ -17,22 +17,19 @@
* @subpackage Formatter
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: Simple.php 10725 2008-08-06 16:01:05Z cadorn $
* @version $Id: Simple.php 13208 2008-12-13 22:33:12Z thomas $
*/
/** Zend_Log_Formatter_Interface */
require_once 'Zend/Log/Formatter/Interface.php';
/** Zend_Log_Exception */
require_once 'Zend/Log/Exception.php';
/**
* @category Zend
* @package Zend_Log
* @subpackage Formatter
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: Simple.php 10725 2008-08-06 16:01:05Z cadorn $
* @version $Id: Simple.php 13208 2008-12-13 22:33:12Z thomas $
*/
class Zend_Log_Formatter_Simple implements Zend_Log_Formatter_Interface
{
@ -56,6 +53,7 @@ class Zend_Log_Formatter_Simple implements Zend_Log_Formatter_Interface
}
if (! is_string($format)) {
require_once 'Zend/Log/Exception.php';
throw new Zend_Log_Exception('Format must be a string');
}
@ -76,7 +74,7 @@ class Zend_Log_Formatter_Simple implements Zend_Log_Formatter_Interface
if ((is_object($value) && !method_exists($value,'__toString'))
|| is_array($value)) {
$value = gettype($value);
$value = gettype($value);
}
$output = str_replace("%$name%", $value, $output);

View File

@ -17,22 +17,19 @@
* @subpackage Writer
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: Abstract.php 8064 2008-02-16 10:58:39Z thomas $
* @version $Id: Abstract.php 13621 2009-01-14 01:53:04Z cadorn $
*/
/** 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-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: Abstract.php 8064 2008-02-16 10:58:39Z thomas $
* @version $Id: Abstract.php 13621 2009-01-14 01:53:04Z cadorn $
*/
abstract class Zend_Log_Writer_Abstract
{
@ -86,7 +83,8 @@ abstract class Zend_Log_Writer_Abstract
* @param Zend_Log_Formatter_Interface $formatter
* @return void
*/
public function setFormatter($formatter) {
public function setFormatter($formatter)
{
$this->_formatter = $formatter;
}

View File

@ -17,7 +17,7 @@
* @subpackage Writer
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: Db.php 8064 2008-02-16 10:58:39Z thomas $
* @version $Id: Db.php 14336 2009-03-16 21:12:38Z wil $
*/
/** Zend_Log_Writer_Abstract */
@ -29,7 +29,7 @@ require_once 'Zend/Log/Writer/Abstract.php';
* @subpackage Writer
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: Db.php 8064 2008-02-16 10:58:39Z thomas $
* @version $Id: Db.php 14336 2009-03-16 21:12:38Z wil $
*/
class Zend_Log_Writer_Db extends Zend_Log_Writer_Abstract
{
@ -71,6 +71,7 @@ class Zend_Log_Writer_Db extends Zend_Log_Writer_Abstract
*/
public function setFormatter($formatter)
{
require_once 'Zend/Log/Exception.php';
throw new Zend_Log_Exception(get_class() . ' does not support formatting');
}
@ -93,7 +94,8 @@ class Zend_Log_Writer_Db extends Zend_Log_Writer_Abstract
protected function _write($event)
{
if ($this->_db === null) {
throw new Zend_Log_Exception('Database adapter instance has been removed by shutdown');
require_once 'Zend/Log/Exception.php';
throw new Zend_Log_Exception('Database adapter is null');
}
if ($this->_columnMap === null) {

View File

@ -25,6 +25,9 @@ require_once 'Zend/Log.php';
/** Zend_Log_Writer_Abstract */
require_once 'Zend/Log/Writer/Abstract.php';
/** Zend_Log_Formatter_Firebug */
require_once 'Zend/Log/Formatter/Firebug.php';
/** Zend_Wildfire_Plugin_FirePhp */
require_once 'Zend/Wildfire/Plugin/FirePhp.php';
@ -73,6 +76,8 @@ class Zend_Log_Writer_Firebug extends Zend_Log_Writer_Abstract
if (php_sapi_name()=='cli') {
$this->setEnabled(false);
}
$this->_formatter = new Zend_Log_Formatter_Firebug();
}
/**
@ -152,18 +157,6 @@ class Zend_Log_Writer_Firebug extends Zend_Log_Writer_Abstract
return false;
}
/**
* Formatting is not possible on this writer
*
* @return void
*/
public function setFormatter($formatter)
{
/** @see Zend_Log_Exception */
require_once 'Zend/Log/Exception.php';
throw new Zend_Log_Exception(get_class() . ' does not support formatting');
}
/**
* Log a message to the Firebug Console.
*
@ -182,6 +175,13 @@ class Zend_Log_Writer_Firebug extends Zend_Log_Writer_Abstract
$type = $this->_defaultPriorityStyle;
}
Zend_Wildfire_Plugin_FirePhp::getInstance()->send($event['message'], null, $type);
$message = $this->_formatter->format($event);
$label = isset($event['firebugLabel'])?$event['firebugLabel']:null;
Zend_Wildfire_Plugin_FirePhp::getInstance()->send($message,
$label,
$type,
array('traceOffset'=>6));
}
}

View File

@ -0,0 +1,278 @@
<?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-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: Mail.php 13626 2009-01-14 18:24:57Z matthew $
*/
/** Zend_Log_Writer_Abstract */
require_once 'Zend/Log/Writer/Abstract.php';
/** Zend_Log_Exception */
require_once 'Zend/Log/Exception.php';
/** Zend_Log_Formatter_Simple*/
require_once 'Zend/Log/Formatter/Simple.php';
/**
* Class used for writing log messages to email via Zend_Mail.
*
* Allows for emailing log messages at and above a certain level via a
* Zend_Mail object. Note that this class only sends the email upon
* completion, so any log entries accumulated are sent in a single email.
*
* @category Zend
* @package Zend_Log
* @subpackage Writer
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: Mail.php 13626 2009-01-14 18:24:57Z matthew $
*/
class Zend_Log_Writer_Mail extends Zend_Log_Writer_Abstract
{
/**
* Array of formatted events to include in message body.
*
* @var array
*/
protected $_eventsToMail = array();
/**
* Array of formatted lines for use in an HTML email body; these events
* are formatted with an optional formatter if the caller is using
* Zend_Layout.
*
* @var array
*/
protected $_layoutEventsToMail = array();
/**
* Zend_Mail instance to use
*
* @var Zend_Mail
*/
protected $_mail;
/**
* Zend_Layout instance to use; optional.
*
* @var Zend_Layout
*/
protected $_layout;
/**
* Optional formatter for use when rendering with Zend_Layout.
*
* @var Zend_Log_Formatter_Interface
*/
protected $_layoutFormatter;
/**
* Array keeping track of the number of entries per priority level.
*
* @var array
*/
protected $_numEntriesPerPriority = array();
/**
* Subject prepend text.
*
* Can only be used of the Zend_Mail object has not already had its
* subject line set. Using this will cause the subject to have the entry
* counts per-priority level appended to it.
*
* @var string|null
*/
protected $_subjectPrependText;
/**
* Class constructor.
*
* Constructs the mail writer; requires a Zend_Mail instance, and takes an
* optional Zend_Layout instance. If Zend_Layout is being used,
* $this->_layout->events will be set for use in the layout template.
*
* @param Zend_Mail $mail Mail instance
* @param Zend_Layout $layout Layout instance; optional
* @return void
*/
public function __construct(Zend_Mail $mail, Zend_Layout $layout = null)
{
$this->_mail = $mail;
$this->_layout = $layout;
$this->_formatter = new Zend_Log_Formatter_Simple();
}
/**
* Places event line into array of lines to be used as message body.
*
* Handles the formatting of both plaintext entries, as well as those
* rendered with Zend_Layout.
*
* @param array $event Event data
* @return void
*/
protected function _write($event)
{
// Track the number of entries per priority level.
if (!isset($this->_numEntriesPerPriority[$event['priorityName']])) {
$this->_numEntriesPerPriority[$event['priorityName']] = 1;
} else {
$this->_numEntriesPerPriority[$event['priorityName']]++;
}
$formattedEvent = $this->_formatter->format($event);
// All plaintext events are to use the standard formatter.
$this->_eventsToMail[] = $formattedEvent;
// If we have a Zend_Layout instance, use a specific formatter for the
// layout if one exists. Otherwise, just use the event with its
// default format.
if ($this->_layout) {
if ($this->_layoutFormatter) {
$this->_layoutEventsToMail[] =
$this->_layoutFormatter->format($event);
} else {
$this->_layoutEventsToMail[] = $formattedEvent;
}
}
}
/**
* Gets instance of Zend_Log_Formatter_Instance used for formatting a
* message using Zend_Layout, if applicable.
*
* @return Zend_Log_Formatter_Interface|null The formatter, or null.
*/
public function getLayoutFormatter()
{
return $this->_layoutFormatter;
}
/**
* Sets a specific formatter for use with Zend_Layout events.
*
* Allows use of a second formatter on lines that will be rendered with
* Zend_Layout. In the event that Zend_Layout is not being used, this
* formatter cannot be set, so an exception will be thrown.
*
* @param Zend_Log_Formatter_Interface $formatter
* @return Zend_Log_Writer_Mail
* @throws Zend_Log_Exception
*/
public function setLayoutFormatter(Zend_Log_Formatter_Interface $formatter)
{
if (!$this->_layout) {
throw new Zend_Log_Exception(
'cannot set formatter for layout; ' .
'a Zend_Layout instance is not in use');
}
$this->_layoutFormatter = $formatter;
return $this;
}
/**
* Allows caller to have the mail subject dynamically set to contain the
* entry counts per-priority level.
*
* Sets the text for use in the subject, with entry counts per-priority
* level appended to the end. Since a Zend_Mail subject can only be set
* once, this method cannot be used if the Zend_Mail object already has a
* subject set.
*
* @param string $subject Subject prepend text.
* @return Zend_Log_Writer_Mail
*/
public function setSubjectPrependText($subject)
{
if ($this->_mail->getSubject()) {
throw new Zend_Log_Exception(
'subject already set on mail; ' .
'cannot set subject prepend text');
}
$this->_subjectPrependText = (string) $subject;
return $this;
}
/**
* Sends mail to recipient(s) if log entries are present. Note that both
* plaintext and HTML portions of email are handled here.
*
* @return void
*/
public function shutdown()
{
// If there are events to mail, use them as message body. Otherwise,
// there is no mail to be sent.
if (empty($this->_eventsToMail)) {
return;
}
if ($this->_subjectPrependText !== null) {
// Tack on the summary of entries per-priority to the subject
// line and set it on the Zend_Mail object.
$numEntries = $this->_getFormattedNumEntriesPerPriority();
$this->_mail->setSubject(
"{$this->_subjectPrependText} ({$numEntries})");
}
// Always provide events to mail as plaintext.
$this->_mail->setBodyText(implode('', $this->_eventsToMail));
// If a Zend_Layout instance is being used, set its "events"
// value to the lines formatted for use with the layout.
if ($this->_layout) {
// Set the required "messages" value for the layout. Here we
// are assuming that the layout is for use with HTML.
$this->_layout->events =
implode('', $this->_layoutEventsToMail);
$this->_mail->setBodyHtml($this->_layout->render());
}
// Finally, send the mail, but re-throw any exceptions at the
// proper level of abstraction.
try {
$this->_mail->send();
} catch (Exception $e) {
throw new Zend_Log_Exception(
$e->getMessage(),
$e->getCode());
}
}
/**
* Gets a string of number of entries per-priority level that occurred, or
* an emptry string if none occurred.
*
* @return string
*/
protected function _getFormattedNumEntriesPerPriority()
{
$strings = array();
foreach ($this->_numEntriesPerPriority as $priority => $numEntries) {
$strings[] = "{$priority}={$numEntries}";
}
return implode(', ', $strings);
}
}

View File

@ -17,7 +17,7 @@
* @subpackage Writer
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: Stream.php 8064 2008-02-16 10:58:39Z thomas $
* @version $Id: Stream.php 14131 2009-02-21 20:13:38Z shahar $
*/
/** Zend_Log_Writer_Abstract */
@ -32,7 +32,7 @@ require_once 'Zend/Log/Formatter/Simple.php';
* @subpackage Writer
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: Stream.php 8064 2008-02-16 10:58:39Z thomas $
* @version $Id: Stream.php 14131 2009-02-21 20:13:38Z shahar $
*/
class Zend_Log_Writer_Stream extends Zend_Log_Writer_Abstract
{
@ -52,16 +52,19 @@ class Zend_Log_Writer_Stream extends Zend_Log_Writer_Abstract
{
if (is_resource($streamOrUrl)) {
if (get_resource_type($streamOrUrl) != 'stream') {
require_once 'Zend/Log/Exception.php';
throw new Zend_Log_Exception('Resource is not a stream');
}
if ($mode != 'a') {
require_once 'Zend/Log/Exception.php';
throw new Zend_Log_Exception('Mode cannot be changed on existing streams');
}
$this->_stream = $streamOrUrl;
} else {
if (! $this->_stream = @fopen($streamOrUrl, $mode, false)) {
require_once 'Zend/Log/Exception.php';
$msg = "\"$streamOrUrl\" cannot be opened with mode \"$mode\"";
throw new Zend_Log_Exception($msg);
}
@ -93,6 +96,7 @@ class Zend_Log_Writer_Stream extends Zend_Log_Writer_Abstract
$line = $this->_formatter->format($event);
if (false === @fwrite($this->_stream, $line)) {
require_once 'Zend/Log/Exception.php';
throw new Zend_Log_Exception("Unable to write to stream");
}
}