pathos 01/04/22 14:57:17 Modified: src/java/org/apache/log4j HTMLLayout.java Log: Added Title option. This can be used to set the document title for the generated HTML file. Revision Changes Path 1.16 +36 -2 jakarta-log4j/src/java/org/apache/log4j/HTMLLayout.java Index: HTMLLayout.java =================================================================== RCS file: /home/cvs/jakarta-log4j/src/java/org/apache/log4j/HTMLLayout.java,v retrieving revision 1.15 retrieving revision 1.16 diff -u -r1.15 -r1.16 --- HTMLLayout.java 2001/04/03 16:37:08 1.15 +++ HTMLLayout.java 2001/04/22 21:57:16 1.16 @@ -43,9 +43,18 @@ */ public static final String LOCATION_INFO_OPTION = "LocationInfo"; + /** + A string constant used in naming the option for setting the the + HTML document title. Current value of this string + constant is <b>Title</b>. + */ + public static final String TITLE_OPTION = "Title"; + // Print no location info by default boolean locationInfo = false; + String title = "Log4J Logging Statements"; + /** Returns a String consisting of one element {@link #LOCATION_INFO_OPTION}. @@ -55,7 +64,7 @@ */ public String[] getOptionStrings() { - return new String[] {LOCATION_INFO_OPTION}; + return new String[] {LOCATION_INFO_OPTION, TITLE_OPTION}; } /** @@ -82,6 +91,9 @@ if (key.equals(LOCATION_INFO_OPTION)) { locationInfo = OptionConverter.toBoolean(value, locationInfo); } + else if (key.equals(TITLE_OPTION)) { + title = value; + } } /** @@ -107,6 +119,25 @@ boolean getLocationInfo() { return locationInfo; } + + /** + The <b>Title</b> option takes a String value. This option sets the + document title of the generated HTML document. + + <p>Defaults to 'Log4J Logging Statements'. + */ + public + void setTitle(String title) { + this.title = title; + } + + /** + Returns the current value of the <b>Title</b> option. + */ + public + String getTitle() { + return title; + } /** Returns the content type output by this layout, i.e "text/html". @@ -208,7 +239,10 @@ public String getHeader() { StringBuffer sbuf = new StringBuffer(); - sbuf.append("<html><body>\r\n"); + sbuf.append("<html>\r\n"); + sbuf.append("<head>\r\n"); + sbuf.append("<title>" + title + "</title>\r\n"); + sbuf.append("<body bgcolor=\"#FFFFFF\">\r\n"); sbuf.append("<table border=\"1\" cellpadding=\"2\">\r\n<tr>\r\n"); sbuf.append("<th>Time</th><th>Thread</th><th>Priority</th><th>Category</th>"); sbuf.append("<th>NDC</th>"); --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]