/** * @return integer a {@link LOGGER_FILTER_NEUTRAL} is there is no string match. */ public function decide(Ideasa_Log4php_LoggerLoggingEvent $event) { $msg = $event->getRenderedMessage(); if ($msg === null or $this->stringToMatch === null) { return Ideasa_Log4php_LoggerFilter::NEUTRAL; } if (strpos($msg, $this->stringToMatch) !== false) { return $this->acceptOnMatch ? Ideasa_Log4php_LoggerFilter::ACCEPT : Ideasa_Log4php_LoggerFilter::DENY; } return Ideasa_Log4php_LoggerFilter::NEUTRAL; }
/** * @param Ideasa_Log4php_LoggerLoggingEvent $event * @return string */ public function convert($event) { switch ($this->type) { case Ideasa_Log4php_Helpers_LoggerPatternParser::RELATIVE_TIME_CONVERTER: $timeStamp = $event->getTimeStamp(); $startTime = Ideasa_Log4php_LoggerLoggingEvent::getStartTime(); return (string) (int) ($timeStamp * 1000 - $startTime * 1000); case Ideasa_Log4php_Helpers_LoggerPatternParser::THREAD_CONVERTER: return $event->getThreadName(); case Ideasa_Log4php_Helpers_LoggerPatternParser::LEVEL_CONVERTER: $level = $event->getLevel(); return $level->toString(); case Ideasa_Log4php_Helpers_LoggerPatternParser::NDC_CONVERTER: return $event->getNDC(); case Ideasa_Log4php_Helpers_LoggerPatternParser::MESSAGE_CONVERTER: return $event->getRenderedMessage(); default: return ''; } }
/** * Returns the log statement in a format consisting of the * <b>level</b>, followed by " - " and then the * <b>message</b>. For example, * <samp> INFO - "A message" </samp> * * @param Ideasa_Log4php_LoggerLoggingEvent $event * @return string */ public function format(Ideasa_Log4php_LoggerLoggingEvent $event) { $level = $event->getLevel(); $message = $event->getRenderedMessage(); return "{$level} - {$message}" . PHP_EOL; }
/** * 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 Ideasa_Log4php_LoggerLoggingEvent $event * @return string */ public function format(Ideasa_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; }
/** * Override this method to create your own layout format. * * @param Ideasa_Log4php_LoggerLoggingEvent * @return string */ public function format(Ideasa_Log4php_LoggerLoggingEvent $event) { return $event->getRenderedMessage(); }
/** * Formats a {@link Ideasa_Log4php_LoggerLoggingEvent} in conformance with the log4php.dtd. * * @param Ideasa_Log4php_LoggerLoggingEvent $event * @return string */ public function format(Ideasa_Log4php_LoggerLoggingEvent $event) { $loggerName = $event->getLoggerName(); $timeStamp = number_format((double) ($event->getTimeStamp() * 1000), 0, '', ''); $thread = $event->getThreadName(); $level = $event->getLevel(); $levelStr = $level->toString(); $buf = "<{$this->_namespacePrefix}:event logger=\"{$loggerName}\" level=\"{$levelStr}\" thread=\"{$thread}\" timestamp=\"{$timeStamp}\">" . PHP_EOL; $buf .= "<{$this->_namespacePrefix}:message><![CDATA["; $this->appendEscapingCDATA($buf, $event->getRenderedMessage()); $buf .= "]]></{$this->_namespacePrefix}:message>" . PHP_EOL; $ndc = $event->getNDC(); if ($ndc != null) { $buf .= "<{$this->_namespacePrefix}:NDC><![CDATA["; $this->appendEscapingCDATA($buf, $ndc); $buf .= "]]></{$this->_namespacePrefix}:NDC>" . PHP_EOL; } if ($this->getLocationInfo()) { $locationInfo = $event->getLocationInformation(); $buf .= "<{$this->_namespacePrefix}:locationInfo " . "class=\"" . $locationInfo->getClassName() . "\" " . "file=\"" . htmlentities($locationInfo->getFileName(), ENT_QUOTES) . "\" " . "line=\"" . $locationInfo->getLineNumber() . "\" " . "method=\"" . $locationInfo->getMethodName() . "\" "; $buf .= "/>" . PHP_EOL; } $buf .= "</{$this->_namespacePrefix}:event>" . PHP_EOL . PHP_EOL; return $buf; }
public function append(Ideasa_Log4php_LoggerLoggingEvent $event) { if ($this->_option == NULL) { $this->_option = LOG_PID | LOG_CONS; } $level = $event->getLevel(); if ($this->layout === null) { $message = $event->getRenderedMessage(); } else { $message = $this->layout->format($event); } // If the priority of a syslog message can be overridden by a value defined in the properties-file, // use that value, else use the one that is defined in the code. if (!$this->dry) { // Attach the process ID to the message, use the facility defined in the .properties-file openlog($this->_ident, $this->_option, $this->_facility); if ($this->_overridePriority) { syslog($this->_priority, $message); } else { if ($level->isGreaterOrEqual(Ideasa_Log4php_LoggerLevel::getLevelFatal())) { syslog(LOG_ALERT, $message); } else { if ($level->isGreaterOrEqual(Ideasa_Log4php_LoggerLevel::getLevelError())) { syslog(LOG_ERR, $message); } else { if ($level->isGreaterOrEqual(Ideasa_Log4php_LoggerLevel::getLevelWarn())) { syslog(LOG_WARNING, $message); } else { if ($level->isGreaterOrEqual(Ideasa_Log4php_LoggerLevel::getLevelInfo())) { syslog(LOG_INFO, $message); } else { if ($level->isGreaterOrEqual(Ideasa_Log4php_LoggerLevel::getLevelDebug())) { syslog(LOG_DEBUG, $message); } else { if ($level->isGreaterOrEqual(Ideasa_Log4php_LoggerLevel::getLevelTrace())) { syslog(LOG_DEBUG, $message); // No trace level in syslog } } } } } } } closelog(); } else { echo "DRY MODE OF SYSLOG APPENDER: " . $message; } }
/** * @param Ideasa_Log4php_LoggerLoggingEvent $event * @return string */ public function format(Ideasa_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(Ideasa_Log4php_LoggerLevel::getLevelDebug())) { $sbuf .= "<font color=\"#339933\">{$level}</font>"; } else { if ($level->equals(Ideasa_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; }