import v1.1.0_RC2 | 2009-09-20
This commit is contained in:
@ -15,9 +15,9 @@
|
||||
* @category Zend
|
||||
* @package Zend_Log
|
||||
* @subpackage Writer
|
||||
* @copyright Copyright (c) 2005-2008 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: Abstract.php 13621 2009-01-14 01:53:04Z cadorn $
|
||||
* @version $Id: Abstract.php 16219 2009-06-21 19:45:39Z thomas $
|
||||
*/
|
||||
|
||||
/** Zend_Log_Filter_Priority */
|
||||
@ -27,9 +27,9 @@ require_once 'Zend/Log/Filter/Priority.php';
|
||||
* @category Zend
|
||||
* @package Zend_Log
|
||||
* @subpackage Writer
|
||||
* @copyright Copyright (c) 2005-2008 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: Abstract.php 13621 2009-01-14 01:53:04Z cadorn $
|
||||
* @version $Id: Abstract.php 16219 2009-06-21 19:45:39Z thomas $
|
||||
*/
|
||||
abstract class Zend_Log_Writer_Abstract
|
||||
{
|
||||
|
@ -15,9 +15,9 @@
|
||||
* @category Zend
|
||||
* @package Zend_Log
|
||||
* @subpackage Writer
|
||||
* @copyright Copyright (c) 2005-2008 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: Db.php 14336 2009-03-16 21:12:38Z wil $
|
||||
* @version $Id: Db.php 16219 2009-06-21 19:45:39Z thomas $
|
||||
*/
|
||||
|
||||
/** 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-2008 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: Db.php 14336 2009-03-16 21:12:38Z wil $
|
||||
* @version $Id: Db.php 16219 2009-06-21 19:45:39Z thomas $
|
||||
*/
|
||||
class Zend_Log_Writer_Db extends Zend_Log_Writer_Abstract
|
||||
{
|
||||
|
@ -15,8 +15,9 @@
|
||||
* @category Zend
|
||||
* @package Zend_Log
|
||||
* @subpackage Writer
|
||||
* @copyright Copyright (c) 2005-2008 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: Firebug.php 16971 2009-07-22 18:05:45Z mikaelkael $
|
||||
*/
|
||||
|
||||
/** Zend_Log */
|
||||
@ -37,7 +38,7 @@ require_once 'Zend/Wildfire/Plugin/FirePhp.php';
|
||||
* @category Zend
|
||||
* @package Zend_Log
|
||||
* @subpackage Writer
|
||||
* @copyright Copyright (c) 2005-2008 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
|
||||
*/
|
||||
class Zend_Log_Writer_Firebug extends Zend_Log_Writer_Abstract
|
||||
|
@ -15,9 +15,9 @@
|
||||
* @category Zend
|
||||
* @package Zend_Log
|
||||
* @subpackage Writer
|
||||
* @copyright Copyright (c) 2005-2008 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: Mail.php 13626 2009-01-14 18:24:57Z matthew $
|
||||
* @version $Id: Mail.php 16219 2009-06-21 19:45:39Z thomas $
|
||||
*/
|
||||
|
||||
/** 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-2008 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: Mail.php 13626 2009-01-14 18:24:57Z matthew $
|
||||
* @version $Id: Mail.php 16219 2009-06-21 19:45:39Z thomas $
|
||||
*/
|
||||
class Zend_Log_Writer_Mail extends Zend_Log_Writer_Abstract
|
||||
{
|
||||
@ -245,17 +245,34 @@ class Zend_Log_Writer_Mail extends Zend_Log_Writer_Abstract
|
||||
// are assuming that the layout is for use with HTML.
|
||||
$this->_layout->events =
|
||||
implode('', $this->_layoutEventsToMail);
|
||||
$this->_mail->setBodyHtml($this->_layout->render());
|
||||
|
||||
// If an exception occurs during rendering, convert it to a notice
|
||||
// so we can avoid an exception thrown without a stack frame.
|
||||
try {
|
||||
$this->_mail->setBodyHtml($this->_layout->render());
|
||||
} catch (Exception $e) {
|
||||
trigger_error(
|
||||
"exception occurred when rendering layout; " .
|
||||
"unable to set html body for message; " .
|
||||
"message = {$e->getMessage()}; " .
|
||||
"code = {$e->getCode()}; " .
|
||||
"exception class = " . get_class($e),
|
||||
E_USER_NOTICE);
|
||||
}
|
||||
}
|
||||
|
||||
// Finally, send the mail, but re-throw any exceptions at the
|
||||
// proper level of abstraction.
|
||||
// Finally, send the mail. If an exception occurs, convert it into a
|
||||
// warning-level message so we can avoid an exception thrown without a
|
||||
// stack frame.
|
||||
try {
|
||||
$this->_mail->send();
|
||||
} catch (Exception $e) {
|
||||
throw new Zend_Log_Exception(
|
||||
$e->getMessage(),
|
||||
$e->getCode());
|
||||
trigger_error(
|
||||
"unable to send log entries via email; " .
|
||||
"message = {$e->getMessage()}; " .
|
||||
"code = {$e->getCode()}; " .
|
||||
"exception class = " . get_class($e),
|
||||
E_USER_WARNING);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -15,9 +15,9 @@
|
||||
* @category Zend
|
||||
* @package Zend_Log
|
||||
* @subpackage Writer
|
||||
* @copyright Copyright (c) 2005-2008 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: Null.php 3980 2007-03-15 21:38:38Z mike $
|
||||
* @version $Id: Mock.php 16971 2009-07-22 18:05:45Z mikaelkael $
|
||||
*/
|
||||
|
||||
/** 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-2008 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: Null.php 3980 2007-03-15 21:38:38Z mike $
|
||||
* @version $Id: Mock.php 16971 2009-07-22 18:05:45Z mikaelkael $
|
||||
*/
|
||||
class Zend_Log_Writer_Mock extends Zend_Log_Writer_Abstract
|
||||
{
|
||||
|
@ -15,9 +15,9 @@
|
||||
* @category Zend
|
||||
* @package Zend_Log
|
||||
* @subpackage Writer
|
||||
* @copyright Copyright (c) 2005-2008 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: Null.php 8064 2008-02-16 10:58:39Z thomas $
|
||||
* @version $Id: Null.php 16219 2009-06-21 19:45:39Z thomas $
|
||||
*/
|
||||
|
||||
/** 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-2008 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: Null.php 8064 2008-02-16 10:58:39Z thomas $
|
||||
* @version $Id: Null.php 16219 2009-06-21 19:45:39Z thomas $
|
||||
*/
|
||||
class Zend_Log_Writer_Null extends Zend_Log_Writer_Abstract
|
||||
{
|
||||
|
@ -15,9 +15,9 @@
|
||||
* @category Zend
|
||||
* @package Zend_Log
|
||||
* @subpackage Writer
|
||||
* @copyright Copyright (c) 2005-2008 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: Stream.php 14131 2009-02-21 20:13:38Z shahar $
|
||||
* @version $Id: Stream.php 16219 2009-06-21 19:45:39Z thomas $
|
||||
*/
|
||||
|
||||
/** 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-2008 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: Stream.php 14131 2009-02-21 20:13:38Z shahar $
|
||||
* @version $Id: Stream.php 16219 2009-06-21 19:45:39Z thomas $
|
||||
*/
|
||||
class Zend_Log_Writer_Stream extends Zend_Log_Writer_Abstract
|
||||
{
|
||||
|
175
libs/Zend/Log/Writer/Syslog.php
Normal file
175
libs/Zend/Log/Writer/Syslog.php
Normal file
@ -0,0 +1,175 @@
|
||||
<?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-2009 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 $
|
||||
*/
|
||||
|
||||
/** Zend_Log_Writer_Abstract */
|
||||
require_once 'Zend/Log/Writer/Abstract.php';
|
||||
|
||||
/**
|
||||
* Writes log messages to syslog
|
||||
*
|
||||
* @category Zend
|
||||
* @package Zend_Log
|
||||
* @subpackage Writer
|
||||
* @copyright Copyright (c) 2005-2009 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
|
||||
{
|
||||
/**
|
||||
* Maps Zend_Log priorities to PHP's syslog priorities
|
||||
* @var array
|
||||
*/
|
||||
protected $_priorities = array(
|
||||
Zend_Log::EMERG => LOG_EMERG,
|
||||
Zend_Log::ALERT => LOG_ALERT,
|
||||
Zend_Log::CRIT => LOG_CRIT,
|
||||
Zend_Log::ERR => LOG_ERR,
|
||||
Zend_Log::WARN => LOG_WARNING,
|
||||
Zend_Log::NOTICE => LOG_NOTICE,
|
||||
Zend_Log::INFO => LOG_INFO,
|
||||
Zend_Log::DEBUG => LOG_DEBUG,
|
||||
);
|
||||
|
||||
/**
|
||||
* 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 string
|
||||
*/
|
||||
protected $_facility = LOG_USER;
|
||||
|
||||
/**
|
||||
* Class constructor
|
||||
*
|
||||
* @param array $options Array of options; may include "application" and "facility" keys
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(array $params = array())
|
||||
{
|
||||
if (isset($params['application'])) {
|
||||
$this->_application = $params['application'];
|
||||
}
|
||||
if (isset($params['facility'])) {
|
||||
$this->_facility = $params['facility'];
|
||||
}
|
||||
$this->_initializeSyslog();
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialize syslog / set application name and facility
|
||||
*
|
||||
* @param string $application Application name
|
||||
* @param string $facility Syslog facility
|
||||
* @return void
|
||||
*/
|
||||
protected function _initializeSyslog()
|
||||
{
|
||||
self::$_lastApplication = $this->_application;
|
||||
self::$_lastFacility = $this->_facility;
|
||||
openlog($this->_application, LOG_PID, $this->_facility);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set syslog facility
|
||||
*
|
||||
* @param string $facility Syslog facility
|
||||
* @return void
|
||||
*/
|
||||
public function setFacility($facility)
|
||||
{
|
||||
if ($this->_facility === $facility) {
|
||||
return;
|
||||
}
|
||||
$this->_facility = $facility;
|
||||
$this->_initializeSyslog();
|
||||
}
|
||||
|
||||
/**
|
||||
* Set application name
|
||||
*
|
||||
* @param string $application Application name
|
||||
* @return void
|
||||
*/
|
||||
public function setApplicationName($application)
|
||||
{
|
||||
if ($this->_application === $application) {
|
||||
return;
|
||||
}
|
||||
$this->_application = $application;
|
||||
$this->_initializeSyslog();
|
||||
}
|
||||
|
||||
/**
|
||||
* Close syslog.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function shutdown()
|
||||
{
|
||||
closelog();
|
||||
}
|
||||
|
||||
/**
|
||||
* Write a message to syslog.
|
||||
*
|
||||
* @param array $event event data
|
||||
* @return void
|
||||
*/
|
||||
protected function _write($event)
|
||||
{
|
||||
if (array_key_exists($event['priority'], $this->_priorities)) {
|
||||
$priority = $this->_priorities[$event['priority']];
|
||||
} else {
|
||||
$priority = $this->_defaultPriority;
|
||||
}
|
||||
|
||||
if ($this->_application !== self::$_lastApplication
|
||||
|| $this->_facility !== self::$_lastFacility)
|
||||
{
|
||||
$this->_initializeSyslog();
|
||||
}
|
||||
|
||||
syslog($priority, $event['message']);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user