* @since Log 1.7.0 * @package Log * * @example win.php Using the window handler. */ class Log_win extends Log { /** * The name of the output window. * @var string * @access private */ var $_name = 'LogWindow'; /** * The title of the output window. * @var string * @access private */ var $_title = 'Log Output Window'; /** * Mapping of log priorities to styles. * @var array * @access private */ var $_styles = 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;' ); /** * String buffer that holds line that are pending output. * @var array * @access private */ var $_buffer = array(); /** * Constructs a new Log_win object. * * @param string $name Ignored. * @param string $ident The identity string. * @param array $conf The configuration array. * @param int $level Log messages up to and including this level. * @access public */ function Log_win($name, $ident = '', $conf = array(), $level = PEAR_LOG_DEBUG) { $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')); } /** * Destructor */ function _Log_win() { if ($this->_opened || (count($this->_buffer) > 0)) { $this->close(); } } /** * 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 */ function open() { if (!$this->_opened) { $win = $this->_name; $styles = $this->_styles; if (!empty($this->_ident)) { $identHeader = "$win.document.writeln('