LocationInfo option takes a boolean value. By * default, it is set to false which means there will be no location * information output by this layout. If the the option is set to * true, then the file name and line number of the statement * at the origin of the log statement will be output. * *

If you are embedding this layout within a {@link LoggerAppenderMail} * or a {@link LoggerAppenderMailEvent} then make sure to set the * LocationInfo option of that appender as well. * @var boolean */ var $locationInfo = false; /** * The Title option takes a String value. This option sets the * document title of the generated HTML document. * Defaults to 'Log4php Log Messages'. * @var string */ var $title = "Log4php Log Messages"; /** * Constructor */ function LoggerLayoutHtml() { return; } /** * The LocationInfo option takes a boolean value. By * default, it is set to false which means there will be no location * information output by this layout. If the the option is set to * true, then the file name and line number of the statement * at the origin of the log statement will be output. * *

If you are embedding this layout within a {@link LoggerAppenderMail} * or a {@link LoggerAppenderMailEvent} then make sure to set the * LocationInfo option of that appender as well. */ function setLocationInfo($flag) { if (is_bool($flag)) { $this->locationInfo = $flag; } else { $this->locationInfo = (bool)(strtolower($flag) == 'true'); } } /** * Returns the current value of the LocationInfo option. */ function getLocationInfo() { return $this->locationInfo; } /** * The Title option takes a String value. This option sets the * document title of the generated HTML document. * Defaults to 'Log4php Log Messages'. */ function setTitle($title) { $this->title = $title; } /** * @return string Returns the current value of the Title option. */ function getTitle() { return $this->title; } /** * @return string Returns the content type output by this layout, i.e "text/html". */ function getContentType() { return "text/html"; } /** * No options to activate. */ function activateOptions() { return true; } /** * @param LoggerLoggingEvent $event * @return string */ function format($event) { $sbuf = LOG4PHP_LINE_SEP . "" . LOG4PHP_LINE_SEP; $sbuf .= ""; $eventTime = (float)$event->getTimeStamp(); $eventStartTime = (float)LoggerLoggingEvent::getStartTime(); $sbuf .= number_format(($eventTime - $eventStartTime) * 1000, 0, '', ''); $sbuf .= "" . LOG4PHP_LINE_SEP; $sbuf .= "getThreadName() . " thread\">"; $sbuf .= $event->getThreadName(); $sbuf .= "" . LOG4PHP_LINE_SEP; $sbuf .= ""; $level = $event->getLevel(); if ($level->equals(LoggerLevel::getLevelDebug())) { $sbuf .= ""; $sbuf .= $level->toString(); $sbuf .= ""; }elseif($level->equals(LoggerLevel::getLevelWarn())) { $sbuf .= ""; $sbuf .= $level->toString(); $sbuf .= ""; } else { $sbuf .= $level->toString(); } $sbuf .= "" . LOG4PHP_LINE_SEP; $sbuf .= "getLoggerName(), ENT_QUOTES) . " category\">"; $sbuf .= htmlentities($event->getLoggerName(), ENT_QUOTES); $sbuf .= "" . LOG4PHP_LINE_SEP; if ($this->locationInfo) { $locInfo = $event->getLocationInformation(); $sbuf .= ""; $sbuf .= htmlentities($locInfo->getFileName(), ENT_QUOTES). ':' . $locInfo->getLineNumber(); $sbuf .= "" . LOG4PHP_LINE_SEP; } $sbuf .= ""; $sbuf .= htmlentities($event->getRenderedMessage(), ENT_QUOTES); $sbuf .= "" . LOG4PHP_LINE_SEP; $sbuf .= "" . LOG4PHP_LINE_SEP; if ($event->getNDC() != null) { $sbuf .= ""; $sbuf .= "NDC: " . htmlentities($event->getNDC(), ENT_QUOTES); $sbuf .= "" . LOG4PHP_LINE_SEP; } return $sbuf; } /** * @return string Returns appropriate HTML headers. */ function getHeader() { $sbuf = "" . LOG4PHP_LINE_SEP; $sbuf .= "" . LOG4PHP_LINE_SEP; $sbuf .= "" . LOG4PHP_LINE_SEP; $sbuf .= "" . $this->title . "" . LOG4PHP_LINE_SEP; $sbuf .= "" . LOG4PHP_LINE_SEP; $sbuf .= "" . LOG4PHP_LINE_SEP; $sbuf .= "" . LOG4PHP_LINE_SEP; $sbuf .= "


" . LOG4PHP_LINE_SEP; $sbuf .= "Log session start time " . strftime('%c', time()) . "
" . LOG4PHP_LINE_SEP; $sbuf .= "
" . LOG4PHP_LINE_SEP; $sbuf .= "" . LOG4PHP_LINE_SEP; $sbuf .= "" . LOG4PHP_LINE_SEP; $sbuf .= "" . LOG4PHP_LINE_SEP; $sbuf .= "" . LOG4PHP_LINE_SEP; $sbuf .= "" . LOG4PHP_LINE_SEP; $sbuf .= "" . LOG4PHP_LINE_SEP; if ($this->locationInfo) $sbuf .= "" . LOG4PHP_LINE_SEP; $sbuf .= "" . LOG4PHP_LINE_SEP; $sbuf .= "" . LOG4PHP_LINE_SEP; return $sbuf; } /** * @return string Returns the appropriate HTML footers. */ function getFooter() { $sbuf = "
TimeThreadLevelCategoryFile:LineMessage
" . LOG4PHP_LINE_SEP; $sbuf .= "
" . LOG4PHP_LINE_SEP; $sbuf .= ""; return $sbuf; } }