ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
display.php
Go to the documentation of this file.
1<?php
22class 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}
const PEAR_LOG_DEBUG
Definition: Log.php:17
Log_display($name='', $ident='', $conf=array(), $level=PEAR_LOG_DEBUG)
Constructs a new Log_display object.
Definition: display.php:49
open()
Opens the display handler.
Definition: display.php:104
close()
Closes the display handler.
Definition: display.php:116
log($message, $priority=null)
Writes $message to the text browser.
Definition: display.php:134
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 ...