/** * Write a message to the log. * * @param array $event Log event. * * @return boolean True. */ public function write($event) { if (!empty($this->_options['ident'])) { $event['message'] = $this->_options['ident'] . ' ' . $event['message']; } $category = isset($event['category']) ? $event['category'] : $this->_options['category']; $message = $this->_formatter->format($event); if (!$this->_options['addNewline']) { $message = rtrim($message); } $this->_scribe->log($category, $message); return true; }
/** * Write a message to the log. * * @param array $event Log event. * * @return boolean True. * @throws Horde_Log_Exception */ public function write($event) { if (!empty($this->_options['ident'])) { $event['message'] = $this->_options['ident'] . ' ' . $event['message']; } $line = $this->_formatter->format($event); if (!@fwrite($this->_stream, $line)) { throw new Horde_Log_Exception(__CLASS__ . ': Unable to write to stream'); } return true; }
/** * Flush the buffer. */ 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(); }