ILIAS  Release_4_0_x_branch Revision 61816
 All Data Structures Namespaces Files Functions Variables Groups Pages
display.php
Go to the documentation of this file.
1 <?php
22 class Log_display extends Log
23 {
29  var $_lineFormat = '<b>%3$s</b>: %4$s';
30 
38  var $_timeFormat = '%b %d %H:%M:%S';
39 
49  function Log_display($name = '', $ident = '', $conf = array(),
50  $level = PEAR_LOG_DEBUG)
51  {
52  $this->_id = md5(microtime());
53  $this->_ident = $ident;
54  $this->_mask = Log::UPTO($level);
55 
56  /* Start by configuring the line format. */
57  if (!empty($conf['lineFormat'])) {
58  $this->_lineFormat = str_replace(array_keys($this->_formatMap),
59  array_values($this->_formatMap),
60  $conf['lineFormat']);
61  }
62 
63  /* We may need to prepend a string to our line format. */
64  $prepend = null;
65  if (isset($conf['error_prepend'])) {
66  $prepend = $conf['error_prepend'];
67  } else {
68  $prepend = ini_get('error_prepend_string');
69  }
70  if (!empty($prepend)) {
71  $this->_lineFormat = $prepend . $this->_lineFormat;
72  }
73 
74  /* We may also need to append a string to our line format. */
75  $append = null;
76  if (isset($conf['error_append'])) {
77  $append = $conf['error_append'];
78  } else {
79  $append = ini_get('error_append_string');
80  }
81  if (!empty($append)) {
82  $this->_lineFormat .= $append;
83  }
84 
85  /* Lastly, the line ending sequence is also configurable. */
86  if (isset($conf['linebreak'])) {
87  $this->_lineFormat .= $conf['linebreak'];
88  } else {
89  $this->_lineFormat .= "<br />\n";
90  }
91 
92  /* The user can also change the time format. */
93  if (!empty($conf['timeFormat'])) {
94  $this->_timeFormat = $conf['timeFormat'];
95  }
96  }
97 
104  function open()
105  {
106  $this->_opened = true;
107  return true;
108  }
109 
116  function close()
117  {
118  $this->_opened = false;
119  return true;
120  }
121 
134  function log($message, $priority = null)
135  {
136  /* If a priority hasn't been specified, use the default value. */
137  if ($priority === null) {
138  $priority = $this->_priority;
139  }
140 
141  /* Abort early if the priority is above the maximum logging level. */
142  if (!$this->_isMasked($priority)) {
143  return false;
144  }
145 
146  /* Extract the string representation of the message. */
147  $message = $this->_extractMessage($message);
148 
149  /* Build and output the complete log line. */
150  echo $this->_format($this->_lineFormat,
151  strftime($this->_timeFormat),
152  $priority,
153  nl2br(htmlspecialchars($message)));
154 
155  /* Notify observers about this log message. */
156  $this->_announce(array('priority' => $priority, 'message' => $message));
157 
158  return true;
159  }
160 
161 }