/** * 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()))); }
/** * Creates a string representation * * @return string */ public function toString() { return sprintf('%s(%s @ %s, PID %d) {%s}%s', nameof($this), LogLevel::nameOf($this->level), date('r', $this->timestamp), $this->processId, null === ($context = $this->getContext()) ? '' : ' ' . $context->toString(), \xp::stringOf($this->arguments)); }
/** * 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; }