/** * Append data * * @param util.log.LoggingEvent event */ public function append(LoggingEvent $event) { $l = $event->getLevel(); fwrite(STDERR, "[" . $this->colors[isset($this->colors[$l]) ? $l : LogLevel::NONE] . "m"); fwrite(STDERR, $this->layout->format($event)); fwrite(STDERR, "[0m"); }
/** * Append data * * @param util.log.LoggingEvent event */ public function append(LoggingEvent $event) { if ($this->identifier != $this->lastIdentifier) { closelog(); openlog($this->identifier ? $this->identifier : basename($_SERVER['PHP_SELF']), LOG_ODELAY | LOG_PID, $this->facility); $this->lastIdentifier = $this->identifier; } static $map = array(LogLevel::INFO => LOG_INFO, LogLevel::WARN => LOG_WARNING, LogLevel::ERROR => LOG_ERR, LogLevel::DEBUG => LOG_DEBUG, LogLevel::NONE => LOG_NOTICE); $l = $event->getLevel(); syslog($map[isset($map[$l]) ? $l : LogLevel::NONE], $this->layout->format($event)); }
/** * Formats a logging event according to this layout * * @param util.log.LoggingEvent event * @return string */ public function format(LoggingEvent $event) { $out = ''; foreach ($this->format as $token) { switch ($token) { case '%m': $out .= implode(' ', array_map(array($this, 'stringOf'), $event->getArguments())); break; case '%t': $out .= gmdate('H:i:s', $event->getTimestamp()); break; case '%c': $out .= $event->getCategory()->identifier; break; case '%l': $out .= strtolower(LogLevel::nameOf($event->getLevel())); break; case '%L': $out .= strtoupper(LogLevel::nameOf($event->getLevel())); break; case '%p': $out .= $event->getProcessId(); break; case '%x': $out .= NULL == ($context = $event->getContext()) ? '' : $context->format(); break; default: $out .= $token; } } return $out; }
/** * Formats a logging event according to this layout * * @param util.log.LoggingEvent event * @return string */ public function format(LoggingEvent $event) { return sprintf("[%s %5d %5s] %s%s\n", date('H:i:s', $event->getTimestamp()), $event->getProcessId(), strtolower(LogLevel::nameOf($event->getLevel())), NULL === ($context = $event->getContext()) ? '' : $context->format() . ' ', implode(' ', array_map(array($this, 'stringOf'), $event->getArguments()))); }