/**
  * Formats a {@link LoggerLoggingEvent} in conformance with the log4php.dtd.
  *
  * @param Payone_Log4php_LoggerLoggingEvent $event
  * @return string
  */
 public function format(Payone_Log4php_LoggerLoggingEvent $event)
 {
     $ns = $this->namespacePrefix;
     $loggerName = $event->getLoggerName();
     $timeStamp = number_format((double) ($event->getTimeStamp() * 1000), 0, '', '');
     $thread = $event->getThreadName();
     $level = $event->getLevel()->toString();
     $buf = "<{$ns}:event logger=\"{$loggerName}\" level=\"{$level}\" thread=\"{$thread}\" timestamp=\"{$timeStamp}\">" . PHP_EOL;
     $buf .= "<{$ns}:message>";
     $buf .= $this->encodeCDATA($event->getRenderedMessage());
     $buf .= "</{$ns}:message>" . PHP_EOL;
     $ndc = $event->getNDC();
     if (!empty($ndc)) {
         $buf .= "<{$ns}:NDC><![CDATA[";
         $buf .= $this->encodeCDATA($ndc);
         $buf .= "]]></{$ns}:NDC>" . PHP_EOL;
     }
     $mdcMap = $event->getMDCMap();
     if (!empty($mdcMap)) {
         $buf .= "<{$ns}:properties>" . PHP_EOL;
         foreach ($mdcMap as $name => $value) {
             $buf .= "<{$ns}:data name=\"{$name}\" value=\"{$value}\" />" . PHP_EOL;
         }
         $buf .= "</{$ns}:properties>" . PHP_EOL;
     }
     if ($this->getLocationInfo()) {
         $locationInfo = $event->getLocationInformation();
         $buf .= "<{$ns}:locationInfo " . "class=\"" . $locationInfo->getClassName() . "\" " . "file=\"" . htmlentities($locationInfo->getFileName(), ENT_QUOTES) . "\" " . "line=\"" . $locationInfo->getLineNumber() . "\" " . "method=\"" . $locationInfo->getMethodName() . "\" ";
         $buf .= "/>" . PHP_EOL;
     }
     $buf .= "</{$ns}:event>" . PHP_EOL;
     return $buf;
 }
Ejemplo n.º 2
0
 /**
  * In addition to the level of the statement and message, the
  * returned string includes time, thread, category.
  * <p>Time, thread, category are printed depending on options.
  *
  * @param Payone_Log4php_LoggerLoggingEvent $event
  * @return string
  */
 public function format(Payone_Log4php_LoggerLoggingEvent $event)
 {
     $timeStamp = (double) $event->getTimeStamp();
     $format = strftime($this->dateFormat, (int) $timeStamp);
     if ($this->microSecondsPrinting) {
         $usecs = floor(($timeStamp - (int) $timeStamp) * 1000);
         $format .= sprintf(',%03d', $usecs);
     }
     $format .= ' ';
     if ($this->threadPrinting) {
         $format .= '[' . getmypid() . '] ';
     }
     $level = $event->getLevel();
     $format .= $level . ' ';
     if ($this->categoryPrefixing) {
         $format .= $event->getLoggerName() . ' ';
     }
     if ($this->contextPrinting) {
         $ndc = $event->getNDC();
         if ($ndc != null) {
             $format .= $ndc . ' ';
         }
     }
     $format .= '- ' . $event->getRenderedMessage();
     $format .= PHP_EOL;
     return $format;
 }
 /**
  * @param Payone_Log4php_LoggerLoggingEvent $event
  * @return string
  */
 public function format(Payone_Log4php_LoggerLoggingEvent $event)
 {
     $sbuf = PHP_EOL . "<tr>" . PHP_EOL;
     $sbuf .= "<td>";
     $sbuf .= $event->getTime();
     $sbuf .= "</td>" . PHP_EOL;
     $sbuf .= "<td title=\"" . $event->getThreadName() . " thread\">";
     $sbuf .= $event->getThreadName();
     $sbuf .= "</td>" . PHP_EOL;
     $sbuf .= "<td title=\"Level\">";
     $level = $event->getLevel();
     if ($level->equals(Payone_Log4php_LoggerLevel::getLevelDebug())) {
         $sbuf .= "<font color=\"#339933\">{$level}</font>";
     } else {
         if ($level->equals(Payone_Log4php_LoggerLevel::getLevelWarn())) {
             $sbuf .= "<font color=\"#993300\"><strong>{$level}</strong></font>";
         } else {
             $sbuf .= $level;
         }
     }
     $sbuf .= "</td>" . PHP_EOL;
     $sbuf .= "<td title=\"" . htmlentities($event->getLoggerName(), ENT_QUOTES) . " category\">";
     $sbuf .= htmlentities($event->getLoggerName(), ENT_QUOTES);
     $sbuf .= "</td>" . PHP_EOL;
     if ($this->locationInfo) {
         $locInfo = $event->getLocationInformation();
         $sbuf .= "<td>";
         $sbuf .= htmlentities($locInfo->getFileName(), ENT_QUOTES) . ':' . $locInfo->getLineNumber();
         $sbuf .= "</td>" . PHP_EOL;
     }
     $sbuf .= "<td title=\"Message\">";
     $sbuf .= htmlentities($event->getRenderedMessage(), ENT_QUOTES);
     $sbuf .= "</td>" . PHP_EOL;
     $sbuf .= "</tr>" . PHP_EOL;
     if ($event->getNDC() != null) {
         $sbuf .= "<tr><td bgcolor=\"#EEEEEE\" style=\"font-size : xx-small;\" colspan=\"6\" title=\"Nested Diagnostic Context\">";
         $sbuf .= "NDC: " . htmlentities($event->getNDC(), ENT_QUOTES);
         $sbuf .= "</td></tr>" . PHP_EOL;
     }
     return $sbuf;
 }
 public function convert(Payone_Log4php_LoggerLoggingEvent $event)
 {
     return $event->getNDC();
 }