ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
Log_win Class Reference
+ Inheritance diagram for Log_win:
+ Collaboration diagram for Log_win:

Public Member Functions

 Log_win ($name, $ident='', $conf=array(), $level=PEAR_LOG_DEBUG)
 Constructs a new Log_win object. More...
 
 _Log_win ()
 Destructor. More...
 
 open ()
 The first time open() is called, it will open a new browser window and prepare it for output. More...
 
 close ()
 Closes the output stream if it is open. More...
 
 _drainBuffer ()
 Writes the contents of the output buffer to the output window. More...
 
 _writeln ($line)
 Writes a single line of text to the output buffer. More...
 
 log ($message, $priority=null)
 Logs $message to the output window. More...
 
- Public Member Functions inherited from Log
 _classExists ($class)
 Utility function which wraps PHP's class_exists() function to ensure consistent behavior between PHP versions 4 and 5. More...
 
factory ($handler, $name='', $ident='', $conf=array(), $level=PEAR_LOG_DEBUG)
 Attempts to return a concrete Log instance of type $handler. More...
 
singleton ($handler, $name='', $ident='', $conf=array(), $level=PEAR_LOG_DEBUG)
 Attempts to return a reference to a concrete Log instance of type $handler, only creating a new instance if no log instance with the same parameters currently exists. More...
 
 open ()
 Abstract implementation of the open() method. More...
 
 close ()
 Abstract implementation of the close() method. More...
 
 flush ()
 Abstract implementation of the flush() method. More...
 
 log ($message, $priority=null)
 Abstract implementation of the log() method. More...
 
 emerg ($message)
 A convenience function for logging a emergency event. More...
 
 alert ($message)
 A convenience function for logging an alert event. More...
 
 crit ($message)
 A convenience function for logging a critical event. More...
 
 err ($message)
 A convenience function for logging a error event. More...
 
 warning ($message)
 A convenience function for logging a warning event. More...
 
 notice ($message)
 A convenience function for logging a notice event. More...
 
 info ($message)
 A convenience function for logging a information event. More...
 
 debug ($message)
 A convenience function for logging a debug event. More...
 
 _extractMessage ($message)
 Returns the string representation of the message data. More...
 
 _getBacktraceVars ($depth)
 Using debug_backtrace(), returns the file, line, and enclosing function name of the source code context from which log() was invoked. More...
 
 _format ($format, $timestamp, $priority, $message)
 Produces a formatted log line based on a format string and a set of variables representing the current log record and state. More...
 
 priorityToString ($priority)
 Returns the string representation of a PEAR_LOG_* integer constant. More...
 
 stringToPriority ($name)
 Returns the the PEAR_LOG_* integer constant for the given string representation of a priority name. More...
 
 MASK ($priority)
 Calculate the log mask for the given priority. More...
 
 UPTO ($priority)
 Calculate the log mask for all priorities up to the given priority. More...
 
 MIN ($priority)
 Calculate the log mask for all priorities greater than or equal to the given priority. More...
 
 MAX ($priority)
 Calculate the log mask for all priorities less than or equal to the given priority. More...
 
 setMask ($mask)
 Set and return the level mask for the current Log instance. More...
 
 getMask ()
 Returns the current level mask. More...
 
 _isMasked ($priority)
 Check if the given priority is included in the current level mask. More...
 
 getPriority ()
 Returns the current default priority. More...
 
 setPriority ($priority)
 Sets the default priority to the specified value. More...
 
 attach (&$observer)
 Adds a Log_observer instance to the list of observers that are listening for messages emitted by this Log instance. More...
 
 detach ($observer)
 Removes a Log_observer instance from the list of observers. More...
 
 _announce ($event)
 Informs each registered observer instance that a new message has been logged. More...
 
 isComposite ()
 Indicates whether this is a composite class. More...
 
 setIdent ($ident)
 Sets this Log instance's identification string. More...
 
 getIdent ()
 Returns the current identification string. More...
 

Data Fields

 $_name = 'LogWindow'
 
 $_title = 'Log Output Window'
 
 $_styles
 
 $_buffer = array()
 
- Data Fields inherited from Log
 $_opened = false
 
 $_id = 0
 
 $_ident = ''
 
 $_priority = PEAR_LOG_INFO
 
 $_mask = PEAR_LOG_ALL
 
 $_listeners = array()
 
 $_formatMap
 

Detailed Description

Definition at line 24 of file win.php.

Member Function Documentation

◆ _drainBuffer()

Log_win::_drainBuffer ( )

Writes the contents of the output buffer to the output window.

@access private

Definition at line 198 of file win.php.

199 {
200 $win = $this->_name;
201 foreach ($this->_buffer as $line) {
202 echo "<script language='JavaScript'>\n";
203 echo "$win.document.writeln('" . addslashes($line) . "');\n";
204 echo "self.focus();\n";
205 echo "</script>\n";
206 }
207
208 /* Now that the buffer has been drained, clear it. */
209 $this->_buffer = array();
210 }
$_name
Definition: win.php:31

References $_name.

Referenced by _writeln(), and close().

+ Here is the caller graph for this function:

◆ _Log_win()

Log_win::_Log_win ( )

Destructor.

Definition at line 98 of file win.php.

99 {
100 if ($this->_opened || (count($this->_buffer) > 0)) {
101 $this->close();
102 }
103 }
close()
Closes the output stream if it is open.
Definition: win.php:173

References close().

+ Here is the call graph for this function:

◆ _writeln()

Log_win::_writeln (   $line)

Writes a single line of text to the output buffer.

Parameters
string$lineThe line of text to write.

@access private

Definition at line 219 of file win.php.

220 {
221 /* Add this line to our output buffer. */
222 $this->_buffer[] = $line;
223
224 /* Buffer the output until this page's headers have been sent. */
225 if (!headers_sent()) {
226 return;
227 }
228
229 /* If we haven't already opened the output window, do so now. */
230 if (!$this->_opened && !$this->open()) {
231 return;
232 }
233
234 /* Drain the buffer to the output window. */
235 $this->_drainBuffer();
236 }
_drainBuffer()
Writes the contents of the output buffer to the output window.
Definition: win.php:198
open()
The first time open() is called, it will open a new browser window and prepare it for output.
Definition: win.php:113

References _drainBuffer(), and open().

Referenced by close(), and log().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ close()

Log_win::close ( )

Closes the output stream if it is open.

If there are still pending lines in the output buffer, the output window will be opened so that the buffer can be drained.

@access public

Reimplemented from Log.

Definition at line 173 of file win.php.

174 {
175 /*
176 * If there are still lines waiting to be written, open the output
177 * window so that we can drain the buffer.
178 */
179 if (!$this->_opened && (count($this->_buffer) > 0)) {
180 $this->open();
181 }
182
183 if ($this->_opened) {
184 $this->_writeln('</table>');
185 $this->_writeln('</body></html>');
186 $this->_drainBuffer();
187 $this->_opened = false;
188 }
189
190 return ($this->_opened === false);
191 }
_writeln($line)
Writes a single line of text to the output buffer.
Definition: win.php:219

References _drainBuffer(), _writeln(), and open().

Referenced by _Log_win().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ log()

Log_win::log (   $message,
  $priority = null 
)

Logs $message to the output window.

The message is also passed along to any Log_observer instances that are observing this Log.

Parameters
mixed$messageString or object containing the message to log.
string$priorityThe priority of the message. Valid values are: PEAR_LOG_EMERG, PEAR_LOG_ALERT, PEAR_LOG_CRIT, PEAR_LOG_ERR, PEAR_LOG_WARNING, PEAR_LOG_NOTICE, PEAR_LOG_INFO, and PEAR_LOG_DEBUG.
Returns
boolean True on success or false on failure. @access public

Reimplemented from Log.

Definition at line 250 of file win.php.

251 {
252 /* If a priority hasn't been specified, use the default value. */
253 if ($priority === null) {
254 $priority = $this->_priority;
255 }
256
257 /* Abort early if the priority is above the maximum logging level. */
258 if (!$this->_isMasked($priority)) {
259 return false;
260 }
261
262 /* Extract the string representation of the message. */
263 $message = $this->_extractMessage($message);
264 $message = preg_replace('/\r\n|\n|\r/', '<br />', $message);
265
266 list($usec, $sec) = explode(' ', microtime());
267
268 /* Build the output line that contains the log entry row. */
269 $line = '<tr>';
270 $line .= sprintf('<td>%s.%s</td>',
271 strftime('%H:%M:%S', $sec), substr($usec, 2, 2));
272 if (!empty($this->_ident)) {
273 $line .= '<td>' . $this->_ident . '</td>';
274 }
275 $line .= '<td>' . ucfirst($this->priorityToString($priority)) . '</td>';
276 $line .= sprintf('<td class="l%d">%s</td>', $priority, $message);
277 $line .= '</tr>';
278
279 $this->_writeln($line);
280
281 $this->_announce(array('priority' => $priority, 'message' => $message));
282
283 return true;
284 }
$_priority
Definition: Log.php:69
_isMasked($priority)
Check if the given priority is included in the current level mask.
Definition: Log.php:726
priorityToString($priority)
Returns the string representation of a PEAR_LOG_* integer constant.
Definition: Log.php:566
_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

References Log\$_priority, Log\_announce(), Log\_extractMessage(), Log\_isMasked(), _writeln(), and Log\priorityToString().

+ Here is the call graph for this function:

◆ Log_win()

Log_win::Log_win (   $name,
  $ident = '',
  $conf = array(),
  $level = PEAR_LOG_DEBUG 
)

Constructs a new Log_win object.

Parameters
string$nameIgnored.
string$identThe identity string.
array$confThe configuration array.
int$levelLog messages up to and including this level. @access public

Definition at line 72 of file win.php.

74 {
75 $this->_id = md5(microtime());
76 $this->_name = str_replace(' ', '_', $name);
77 $this->_ident = $ident;
78 $this->_mask = Log::UPTO($level);
79
80 if (isset($conf['title'])) {
81 $this->_title = $conf['title'];
82 }
83 if (isset($conf['styles']) && is_array($conf['styles'])) {
84 $this->_styles = $conf['styles'];
85 }
86 if (isset($conf['colors']) && is_array($conf['colors'])) {
87 foreach ($conf['colors'] as $level => $color) {
88 $this->_styles[$level] .= "color: $color;";
89 }
90 }
91
92 register_shutdown_function(array(&$this, '_Log_win'));
93 }
UPTO($priority)
Calculate the log mask for all priorities up to the given priority.
Definition: Log.php:642

References Log\UPTO().

+ Here is the call graph for this function:

◆ open()

Log_win::open ( )

The first time open() is called, it will open a new browser window and prepare it for output.

This is implicitly called by log(), if necessary.

@access public

Reimplemented from Log.

Definition at line 113 of file win.php.

114 {
115 if (!$this->_opened) {
116 $win = $this->_name;
117 $styles = $this->_styles;
118
119 if (!empty($this->_ident)) {
120 $identHeader = "$win.document.writeln('<th>Ident</th>')";
121 } else {
122 $identHeader = '';
123 }
124
125 echo <<< EOT
126<script language="JavaScript">
127$win = window.open('', '{$this->_name}', 'toolbar=no,scrollbars,width=600,height=400');
128$win.document.writeln('<html>');
129$win.document.writeln('<head>');
130$win.document.writeln('<title>{$this->_title}</title>');
131$win.document.writeln('<style type="text/css">');
132$win.document.writeln('body { font-family: monospace; font-size: 8pt; }');
133$win.document.writeln('td,th { font-size: 8pt; }');
134$win.document.writeln('td,th { border-bottom: #999999 solid 1px; }');
135$win.document.writeln('td,th { border-right: #999999 solid 1px; }');
136$win.document.writeln('tr { text-align: left; vertical-align: top; }');
137$win.document.writeln('td.l0 { $styles[0] }');
138$win.document.writeln('td.l1 { $styles[1] }');
139$win.document.writeln('td.l2 { $styles[2] }');
140$win.document.writeln('td.l3 { $styles[3] }');
141$win.document.writeln('td.l4 { $styles[4] }');
142$win.document.writeln('td.l5 { $styles[5] }');
143$win.document.writeln('td.l6 { $styles[6] }');
144$win.document.writeln('td.l7 { $styles[7] }');
145$win.document.writeln('</style>');
146$win.document.writeln('<script type="text/javascript">');
147$win.document.writeln('function scroll() {');
148$win.document.writeln(' body = document.getElementById("{$this->_name}");');
149$win.document.writeln(' body.scrollTop = body.scrollHeight;');
150$win.document.writeln('}');
151$win.document.writeln('<\/script>');
152$win.document.writeln('</head>');
153$win.document.writeln('<body id="{$this->_name}" onclick="scroll()">');
154$win.document.writeln('<table border="0" cellpadding="2" cellspacing="0">');
155$win.document.writeln('<tr><th>Time</th>');
156$identHeader
157$win.document.writeln('<th>Priority</th><th width="100%">Message</th></tr>');
158</script>
159EOT;
160 $this->_opened = true;
161 }
162
163 return $this->_opened;
164 }
$_styles
Definition: win.php:45
$_opened
Definition: Log.php:45

References $_name, Log\$_opened, and $_styles.

Referenced by _writeln(), and close().

+ Here is the caller graph for this function:

Field Documentation

◆ $_buffer

Log_win::$_buffer = array()

Definition at line 61 of file win.php.

◆ $_name

Log_win::$_name = 'LogWindow'

Definition at line 31 of file win.php.

Referenced by _drainBuffer(), and open().

◆ $_styles

Log_win::$_styles
Initial value:
= array(
PEAR_LOG_EMERG => 'color: red;',
PEAR_LOG_ALERT => 'color: orange;',
PEAR_LOG_CRIT => 'color: yellow;',
PEAR_LOG_ERR => 'color: green;',
PEAR_LOG_WARNING => 'color: blue;',
PEAR_LOG_NOTICE => 'color: indigo;',
PEAR_LOG_INFO => 'color: violet;',
PEAR_LOG_DEBUG => 'color: black;'
)
const PEAR_LOG_ALERT
Definition: Log.php:11
const PEAR_LOG_EMERG
Definition: Log.php:10
const PEAR_LOG_ERR
Definition: Log.php:13
const PEAR_LOG_CRIT
Definition: Log.php:12
const PEAR_LOG_DEBUG
Definition: Log.php:17
const PEAR_LOG_INFO
Definition: Log.php:16
const PEAR_LOG_WARNING
Definition: Log.php:14
const PEAR_LOG_NOTICE
Definition: Log.php:15

Definition at line 45 of file win.php.

Referenced by open().

◆ $_title

Log_win::$_title = 'Log Output Window'

Definition at line 38 of file win.php.


The documentation for this class was generated from the following file: