ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
error_log.php
Go to the documentation of this file.
1<?php
19class Log_error_log extends Log
20{
27
33 var $_destination = '';
34
42
48 var $_lineFormat = '%2$s: %4$s';
49
57 var $_timeFormat = '%b %d %H:%M:%S';
58
68 function Log_error_log($name, $ident = '', $conf = array(),
69 $level = PEAR_LOG_DEBUG)
70 {
71 $this->_id = md5(microtime());
72 $this->_type = $name;
73 $this->_ident = $ident;
74 $this->_mask = Log::UPTO($level);
75
76 if (!empty($conf['destination'])) {
77 $this->_destination = $conf['destination'];
78 }
79
80 if (!empty($conf['extra_headers'])) {
81 $this->_extra_headers = $conf['extra_headers'];
82 }
83
84 if (!empty($conf['lineFormat'])) {
85 $this->_lineFormat = str_replace(array_keys($this->_formatMap),
86 array_values($this->_formatMap),
87 $conf['lineFormat']);
88 }
89
90 if (!empty($conf['timeFormat'])) {
91 $this->_timeFormat = $conf['timeFormat'];
92 }
93 }
94
101 function open()
102 {
103 $this->_opened = true;
104 return true;
105 }
106
113 function close()
114 {
115 $this->_opened = false;
116 return true;
117 }
118
131 function log($message, $priority = null)
132 {
133 /* If a priority hasn't been specified, use the default value. */
134 if ($priority === null) {
135 $priority = $this->_priority;
136 }
137
138 /* Abort early if the priority is above the maximum logging level. */
139 if (!$this->_isMasked($priority)) {
140 return false;
141 }
142
143 /* Extract the string representation of the message. */
144 $message = $this->_extractMessage($message);
145
146 /* Build the string containing the complete log line. */
147 $line = $this->_format($this->_lineFormat,
148 strftime($this->_timeFormat),
149 $priority, $message);
150
151 /* Pass the log line and parameters to the error_log() function. */
152 $success = error_log($line, $this->_type, $this->_destination,
153 $this->_extra_headers);
154
155 $this->_announce(array('priority' => $priority, 'message' => $message));
156
157 return $success;
158 }
159
160}
const PEAR_LOG_DEBUG
Definition: Log.php:17
const PEAR_LOG_TYPE_SYSTEM
Definition: Log.php:23
$success
Definition: Utf8Test.php:87
log($message, $priority=null)
Logs $message using PHP's error_log() function.
Definition: error_log.php:131
Log_error_log($name, $ident='', $conf=array(), $level=PEAR_LOG_DEBUG)
Constructs a new Log_error_log object.
Definition: error_log.php:68
open()
Opens the handler.
Definition: error_log.php:101
close()
Closes the handler.
Definition: error_log.php:113
UPTO($priority)
Calculate the log mask for all priorities up to the given priority.
Definition: Log.php:642
$_priority
Definition: Log.php:69
_isMasked($priority)
Check if the given priority is included in the current level mask.
Definition: Log.php:726
_announce($event)
Informs each registered observer instance that a new message has been logged.
Definition: Log.php:811
_extractMessage($message)
Returns the string representation of the message data.
Definition: Log.php:417
_format($format, $timestamp, $priority, $message)
Produces a formatted log line based on a format string and a set of variables representing the curren...
Definition: Log.php:530
The Log:: class implements both an abstraction for various logging mechanisms and the Subject end of ...