/** * Write a message to the log. * * @param array $event Log event * @return bool Always True */ public function write($event) { $line = $this->_formatter->format($event); if (!@fwrite($this->_stream, $line)) { throw new Horde_Log_Exception("Unable to write to stream"); } return true; }
/** */ public function flush() { if (!count($this->_buffer)) { return true; } $output = array(); foreach ($this->_buffer as $event) { $line = trim($this->_formatter->format($event)); // normalize line breaks $line = str_replace("\r\n", "\n", $line); // escape line breaks $line = str_replace("\n", "\\n\\\n", $line); // escape quotes $line = str_replace('"', '\\"', $line); // firebug call $method = isset(self::$_methods[$event['level']]) ? self::$_methods[$event['level']] : 'log'; $output[] = 'console.' . $method . '("' . $line . '");'; } echo '<script type="text/javascript">' . "\nif (('console' in window) || ('firebug' in console)) {\n" . implode("\n", $output) . "\n" . "}\n" . "</script>\n"; $this->_buffer = array(); }