ILIAS  eassessment Revision 61809
 All Data Structures Namespaces Files Functions Variables Groups Pages
error_log.php
Go to the documentation of this file.
1 <?php
19 class Log_error_log extends Log
20 {
27 
33  var $_destination = '';
34 
41  var $_extra_headers = '';
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 }