Ejemplo n.º 1
0
 /**
  * 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())));
 }
 /**
  * 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;
 }