*
* The corresponding XML file:
*
* {@example ../../examples/resources/layout_html.properties 18}
*
* The above will print a HTML table that looks, converted back to plain text, like the following:
*
* Log session start time Wed Sep 9 00:11:30 2009 * * Time Thread Level Category Message * 0 8318 INFO root Hello World! ** * @version $Revision: 883108 $ * @package log4php * @subpackage layouts */ class LoggerLayoutHtml extends LoggerLayout { /** * 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. * @var boolean */ private $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 */ private $title = "Log4php Log Messages"; /** * Constructor */ public function __construct() { } /** * 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. */ public 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. */ public 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'. */ public function setTitle($title) { $this->title = $title; } /** * @return string Returns the current value of the Title option. */ public function getTitle() { return $this->title; } /** * @return string Returns the content type output by this layout, i.e "text/html". */ public function getContentType() { return "text/html"; } /** * @param LoggerLoggingEvent $event * @return string */ public function format(LoggerLoggingEvent $event) { $sbuf = PHP_EOL . "
Time | " . PHP_EOL; $sbuf .= "Thread | " . PHP_EOL; $sbuf .= "Level | " . PHP_EOL; $sbuf .= "Category | " . PHP_EOL; if ($this->locationInfo) $sbuf .= "File:Line | " . PHP_EOL; $sbuf .= "Message | " . PHP_EOL; $sbuf .= "
---|