<?php
// $Id: error_log.php,v 1.1 2003/09/23 22:07:43 cbooth7575 Exp $
/**
* The Log_error_log class is a concrete implementation of the Log abstract
* class that logs messages using PHP's error_log() function.
*
* @author Jon Parise <hide@address.com>
* @version $Revision: 1.1 $
* @package Log
*/
class Log_error_log extends Log
{
/**
* The error_log() log type.
* @var integer
*/
var $_type = PEAR_LOG_TYPE_SYSTEM;
/**
* The type-specific destination value.
* @var string
*/
var $_destination = '';
/**
* Additional headers to pass to the mail() function when the
* PEAR_LOG_TYPE_MAIL type is used.
* @var string
*/
var $_extra_headers = '';
/**
* Constructs a new Log_error_log object.
*
* @param string $name Ignored.
* @param string $ident The identity string.
* @param array $conf The configuration array.
* @param array $maxLevel Maximum priority level at which to log.
* @access public
*/
function Log_error_log($name, $ident = '', $conf = array(),
$maxLevel = PEAR_LOG_DEBUG)
{
$this->_id = md5(microtime());
$this->_type = $name;
$this->_ident = $ident;
$this->_mask = Log::UPTO($maxLevel);
if (!empty($conf['destination'])) {
$this->_destination = $conf['destination'];
}
if (!empty($conf['extra_headers'])) {
$this->_extra_headers = $conf['extra_headers'];
}
}
/**
* Logs $message using PHP's error_log() function. The message is also
* passed along to any Log_observer instances that are observing this Log.
*
* @param string $message The textual message to be logged.
* @param string $priority The priority of the message. Valid
* values are: PEAR_LOG_EMERG, PEAR_LOG_ALERT,
* PEAR_LOG_CRIT, PEAR_LOG_ERR, PEAR_LOG_WARNING,
* PEAR_LOG_NOTICE, PEAR_LOG_INFO, and PEAR_LOG_DEBUG.
* The default is PEAR_LOG_INFO.
* @return boolean True on success or false on failure.
* @access public
*/
function log($message, $priority = PEAR_LOG_INFO)
{
/* Abort early if the priority is above the maximum logging level. */
if (!$this->_isMasked($priority)) {
return false;
}
$success = error_log($this->_ident . ': ' . $message, $this->_type,
$this->_destination, $this->_extra_headers);
$this->_announce(array('priority' => $priority, 'message' => $message));
return $success;
}
}
?>