ILIAS  release_4-3 Revision
 All Data Structures Namespaces Files Functions Variables Groups Pages
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.
 _Log_win ()
 Destructor.
 open ()
 The first time open() is called, it will open a new browser window and prepare it for output.
 close ()
 Closes the output stream if it is open.
 _drainBuffer ()
 Writes the contents of the output buffer to the output window.
 _writeln ($line)
 Writes a single line of text to the output buffer.
 log ($message, $priority=null)
 Logs $message to the output window.
- 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.
factory ($handler, $name= '', $ident= '', $conf=array(), $level=PEAR_LOG_DEBUG)
 Attempts to return a concrete Log instance of type $handler.
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.
 flush ()
 Abstract implementation of the flush() method.
 emerg ($message)
 A convenience function for logging a emergency event.
 alert ($message)
 A convenience function for logging an alert event.
 crit ($message)
 A convenience function for logging a critical event.
 err ($message)
 A convenience function for logging a error event.
 warning ($message)
 A convenience function for logging a warning event.
 notice ($message)
 A convenience function for logging a notice event.
 info ($message)
 A convenience function for logging a information event.
 debug ($message)
 A convenience function for logging a debug event.
 _extractMessage ($message)
 Returns the string representation of the message data.
 _getBacktraceVars ($depth)
 Using debug_backtrace(), returns the file, line, and enclosing function name of the source code context from which log() was invoked.
 _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.
 priorityToString ($priority)
 Returns the string representation of a PEAR_LOG_* integer constant.
 stringToPriority ($name)
 Returns the the PEAR_LOG_* integer constant for the given string representation of a priority name.
 MASK ($priority)
 Calculate the log mask for the given priority.
 UPTO ($priority)
 Calculate the log mask for all priorities up to the given priority.
 MIN ($priority)
 Calculate the log mask for all priorities greater than or equal to the given priority.
 MAX ($priority)
 Calculate the log mask for all priorities less than or equal to the given priority.
 setMask ($mask)
 Set and return the level mask for the current Log instance.
 getMask ()
 Returns the current level mask.
 _isMasked ($priority)
 Check if the given priority is included in the current level mask.
 getPriority ()
 Returns the current default priority.
 setPriority ($priority)
 Sets the default priority to the specified value.
 attach (&$observer)
 Adds a Log_observer instance to the list of observers that are listening for messages emitted by this Log instance.
 detach ($observer)
 Removes a Log_observer instance from the list of observers.
 _announce ($event)
 Informs each registered observer instance that a new message has been logged.
 isComposite ()
 Indicates whether this is a composite class.
 setIdent ($ident)
 Sets this Log instance's identification string.
 getIdent ()
 Returns the current identification string.

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

Log_win::_drainBuffer ( )

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

private

Definition at line 198 of file win.php.

References $_name.

Referenced by _writeln(), and close().

{
$win = $this->_name;
foreach ($this->_buffer as $line) {
echo "<script language='JavaScript'>\n";
echo "$win.document.writeln('" . addslashes($line) . "');\n";
echo "self.focus();\n";
echo "</script>\n";
}
/* Now that the buffer has been drained, clear it. */
$this->_buffer = array();
}

+ Here is the caller graph for this function:

Log_win::_Log_win ( )

Destructor.

Definition at line 98 of file win.php.

References close().

{
if ($this->_opened || (count($this->_buffer) > 0)) {
$this->close();
}
}

+ Here is the call graph for this function:

Log_win::_writeln (   $line)

Writes a single line of text to the output buffer.

Parameters
string$lineThe line of text to write.

private

Definition at line 219 of file win.php.

References _drainBuffer(), and open().

Referenced by close(), and log().

{
/* Add this line to our output buffer. */
$this->_buffer[] = $line;
/* Buffer the output until this page's headers have been sent. */
if (!headers_sent()) {
return;
}
/* If we haven't already opened the output window, do so now. */
if (!$this->_opened && !$this->open()) {
return;
}
/* Drain the buffer to the output window. */
$this->_drainBuffer();
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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.

public

Reimplemented from Log.

Definition at line 173 of file win.php.

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

Referenced by _Log_win().

{
/*
* If there are still lines waiting to be written, open the output
* window so that we can drain the buffer.
*/
if (!$this->_opened && (count($this->_buffer) > 0)) {
$this->open();
}
if ($this->_opened) {
$this->_writeln('</table>');
$this->_writeln('</body></html>');
$this->_drainBuffer();
$this->_opened = false;
}
return ($this->_opened === false);
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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. public

Reimplemented from Log.

Definition at line 250 of file win.php.

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

{
/* If a priority hasn't been specified, use the default value. */
if ($priority === null) {
$priority = $this->_priority;
}
/* Abort early if the priority is above the maximum logging level. */
if (!$this->_isMasked($priority)) {
return false;
}
/* Extract the string representation of the message. */
$message = $this->_extractMessage($message);
$message = preg_replace('/\r\n|\n|\r/', '<br />', $message);
list($usec, $sec) = explode(' ', microtime());
/* Build the output line that contains the log entry row. */
$line = '<tr>';
$line .= sprintf('<td>%s.%s</td>',
strftime('%H:%M:%S', $sec), substr($usec, 2, 2));
if (!empty($this->_ident)) {
$line .= '<td>' . $this->_ident . '</td>';
}
$line .= '<td>' . ucfirst($this->priorityToString($priority)) . '</td>';
$line .= sprintf('<td class="l%d">%s</td>', $priority, $message);
$line .= '</tr>';
$this->_writeln($line);
$this->_announce(array('priority' => $priority, 'message' => $message));
return true;
}

+ Here is the call graph for this function:

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. public

Definition at line 72 of file win.php.

References Log\UPTO().

{
$this->_id = md5(microtime());
$this->_name = str_replace(' ', '_', $name);
$this->_ident = $ident;
$this->_mask = Log::UPTO($level);
if (isset($conf['title'])) {
$this->_title = $conf['title'];
}
if (isset($conf['styles']) && is_array($conf['styles'])) {
$this->_styles = $conf['styles'];
}
if (isset($conf['colors']) && is_array($conf['colors'])) {
foreach ($conf['colors'] as $level => $color) {
$this->_styles[$level] .= "color: $color;";
}
}
register_shutdown_function(array(&$this, '_Log_win'));
}

+ Here is the call graph for this function:

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.

public

Reimplemented from Log.

Definition at line 113 of file win.php.

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

Referenced by _writeln(), and close().

{
if (!$this->_opened) {
$win = $this->_name;
$styles = $this->_styles;
if (!empty($this->_ident)) {
$identHeader = "$win.document.writeln('<th>Ident</th>')";
} else {
$identHeader = '';
}
echo <<< EOT
<script language="JavaScript">
$win = window.open('', '{$this->_name}', 'toolbar=no,scrollbars,width=600,height=400');
$win.document.writeln('<html>');
$win.document.writeln('<head>');
$win.document.writeln('<title>{$this->_title}</title>');
$win.document.writeln('<style type="text/css">');
$win.document.writeln('body { font-family: monospace; font-size: 8pt; }');
$win.document.writeln('td,th { font-size: 8pt; }');
$win.document.writeln('td,th { border-bottom: #999999 solid 1px; }');
$win.document.writeln('td,th { border-right: #999999 solid 1px; }');
$win.document.writeln('tr { text-align: left; vertical-align: top; }');
$win.document.writeln('td.l0 { $styles[0] }');
$win.document.writeln('td.l1 { $styles[1] }');
$win.document.writeln('td.l2 { $styles[2] }');
$win.document.writeln('td.l3 { $styles[3] }');
$win.document.writeln('td.l4 { $styles[4] }');
$win.document.writeln('td.l5 { $styles[5] }');
$win.document.writeln('td.l6 { $styles[6] }');
$win.document.writeln('td.l7 { $styles[7] }');
$win.document.writeln('</style>');
$win.document.writeln('<script type="text/javascript">');
$win.document.writeln('function scroll() {');
$win.document.writeln(' body = document.getElementById("{$this->_name}");');
$win.document.writeln(' body.scrollTop = body.scrollHeight;');
$win.document.writeln('}');
$win.document.writeln('<\/script>');
$win.document.writeln('</head>');
$win.document.writeln('<body id="{$this->_name}" onclick="scroll()">');
$win.document.writeln('<table border="0" cellpadding="2" cellspacing="0">');
$win.document.writeln('<tr><th>Time</th>');
$identHeader
$win.document.writeln('<th>Priority</th><th width="100%">Message</th></tr>');
</script>
EOT;
$this->_opened = true;
}
}

+ Here is the caller graph for this function:

Field Documentation

Log_win::$_buffer = array()

Definition at line 61 of file win.php.

Log_win::$_name = 'LogWindow'

Definition at line 31 of file win.php.

Referenced by _drainBuffer(), and open().

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;'
)

Definition at line 45 of file win.php.

Referenced by open().

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: