[ Index ] |
|
Code source de SPIP Agora 1.4 |
1 <?php 2 /** 3 * $Header: /repository/pear/Log/Log/error_log.php,v 1.6 2004/01/19 08:02:40 jon Exp $ 4 * 5 * @version $Revision: 1.6 $ 6 * @package Log 7 */ 8 9 /** 10 * The Log_error_log class is a concrete implementation of the Log abstract 11 * class that logs messages using PHP's error_log() function. 12 * 13 * @author Jon Parise <jon@php.net> 14 * @since Log 1.7.0 15 * @package Log 16 * 17 * @example error_log.php Using the error_log handler. 18 */ 19 class Log_error_log extends Log 20 { 21 /** 22 * The error_log() log type. 23 * @var integer 24 * @access private 25 */ 26 var $_type = PEAR_LOG_TYPE_SYSTEM; 27 28 /** 29 * The type-specific destination value. 30 * @var string 31 * @access private 32 */ 33 var $_destination = ''; 34 35 /** 36 * Additional headers to pass to the mail() function when the 37 * PEAR_LOG_TYPE_MAIL type is used. 38 * @var string 39 * @access private 40 */ 41 var $_extra_headers = ''; 42 43 /** 44 * Constructs a new Log_error_log object. 45 * 46 * @param string $name Ignored. 47 * @param string $ident The identity string. 48 * @param array $conf The configuration array. 49 * @param int $level Log messages up to and including this level. 50 * @access public 51 */ 52 function Log_error_log($name, $ident = '', $conf = array(), 53 $level = PEAR_LOG_DEBUG) 54 { 55 $this->_id = md5(microtime()); 56 $this->_type = $name; 57 $this->_ident = $ident; 58 $this->_mask = Log::UPTO($level); 59 60 if (!empty($conf['destination'])) { 61 $this->_destination = $conf['destination']; 62 } 63 if (!empty($conf['extra_headers'])) { 64 $this->_extra_headers = $conf['extra_headers']; 65 } 66 } 67 68 /** 69 * Logs $message using PHP's error_log() function. The message is also 70 * passed along to any Log_observer instances that are observing this Log. 71 * 72 * @param mixed $message String or object containing the message to log. 73 * @param string $priority The priority of the message. Valid 74 * values are: PEAR_LOG_EMERG, PEAR_LOG_ALERT, 75 * PEAR_LOG_CRIT, PEAR_LOG_ERR, PEAR_LOG_WARNING, 76 * PEAR_LOG_NOTICE, PEAR_LOG_INFO, and PEAR_LOG_DEBUG. 77 * @return boolean True on success or false on failure. 78 * @access public 79 */ 80 function log($message, $priority = null) 81 { 82 /* If a priority hasn't been specified, use the default value. */ 83 if ($priority === null) { 84 $priority = $this->_priority; 85 } 86 87 /* Abort early if the priority is above the maximum logging level. */ 88 if (!$this->_isMasked($priority)) { 89 return false; 90 } 91 92 /* Extract the string representation of the message. */ 93 $message = $this->_extractMessage($message); 94 95 $success = error_log($this->_ident . ': ' . $message, $this->_type, 96 $this->_destination, $this->_extra_headers); 97 98 $this->_announce(array('priority' => $priority, 'message' => $message)); 99 100 return $success; 101 } 102 } 103 104 ?>
titre
Description
Corps
titre
Description
Corps
titre
Description
Corps
titre
Corps
Généré le : Sat Feb 24 14:40:03 2007 | par Balluche grâce à PHPXref 0.7 |