The version of Apache log4j used by SoundHelix.
Clone
HTTPS:
git clone https://vervis.peers.community/repos/aEp6o
SSH:
git clone USERNAME@vervis.peers.community:aEp6o
Branches
Tags
- 1.3alpha-7
- CHAINSAW_2_SANDBOX_MERGE
- CORE_VERSION
- LEVEL_REPLACES_PRIORITY
- PREALPHA_1_3_AS_OF_2004_05_12
- PRE_CHAINSAW_MODEL_CONVERSION
- PRE_UGLI_MOVE
- TAG_CHAINSAW2_MOVE
- log4j-1.2.17
- log4j-1.2.17-rc1
- v1.3alpha8
- v1.3alpha8-temp
- v1_2_1
- v1_2_10-recalled
- v1_2_11
- v1_2_11_rc1
- v1_2_11rc3
- v1_2_12
- v1_2_12_rc1
- v1_2_12_rc2
- v1_2_12_rc3
- v1_2_12_rc4
- v1_2_12_rc5
- v1_2_12_rc6
- v1_2_13
- v1_2_13_rc1
- v1_2_13_rc2
- v1_2_13_site_update
- v1_2_14
- v1_2_14_maven
- v1_2_14_rc1
- v1_2_14_site_update
- v1_2_15
- v1_2_15_rc1
- v1_2_15_rc2
- v1_2_15_rc3
- v1_2_15_rc4
- v1_2_15_rc5
- v1_2_15_rc6
- v1_2_16
- v1_2_16_rc1
- v1_2_16_rc2
- v1_2_17
- v1_2_17-rc1
- v1_2_17_rc1
- v1_2_17_rc2
- v1_2_17_rc3
- v1_2_2
- v1_2_3
- v1_2_4
- v1_2_6
- v1_2_7
- v1_2_9
- v1_2_alpha0
- v1_2_alpha7
- v1_2beta1
- v1_2final
- v1_3alpha_1
- v1_3alpha_6
- v_1_0
- v_1_0_1
- v_1_0_4
- v_1_1
- v_1_1_1
- v_1_1_2
- v_1_1_3
- v_1_1_b1
- v_1_1b2
- v_1_1b3
- v_1_1b5
- v_1_1b6
- v_1_1b7
- v_1_2beta3
HTMLLayout.java
/*
* ============================================================================
* The Apache Software License, Version 1.1
* ============================================================================
*
* Copyright (C) 1999 The Apache Software Foundation. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modifica-
* tion, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* 3. The end-user documentation included with the redistribution, if any, must
* include the following acknowledgment: "This product includes software
* developed by the Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself, if
* and wherever such third-party acknowledgments normally appear.
*
* 4. The names "log4j" and "Apache Software Foundation" must not be used to
* endorse or promote products derived from this software without prior
* written permission. For written permission, please contact
* apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache", nor may
* "Apache" appear in their name, without prior written permission of the
* Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU-
* DING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* This software consists of voluntary contributions made by many individuals
* on behalf of the Apache Software Foundation. For more information on the
* Apache Software Foundation, please see <http://www.apache.org/>.
*
*/
package org.apache.log4j;
import java.io.IOException;
import java.io.Writer;
import org.apache.log4j.helpers.Transform;
import org.apache.log4j.spi.LocationInfo;
import org.apache.log4j.spi.LoggingEvent;
/**
This layout outputs events in a HTML table.
@author Ceki Gülcü
*/
public class HTMLLayout extends Layout {
static final String TRACE_PREFIX = "<br> ";
/**
A string constant used in naming the option for setting the the
location information flag. Current value of this string
constant is <b>LocationInfo</b>.
<p>Note that all option keys are case sensitive.
@deprecated Options are now handled using the JavaBeans paradigm.
This constant is not longer needed and will be removed in the
<em>near</em> term.
*/
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";
protected static final int BUF_SIZE = 256;
protected static final int MAX_CAPACITY = 1024;
// output buffer appended to when format() is invoked
private StringBuffer sbuf = new StringBuffer(BUF_SIZE);
// Print no location info by default
boolean locationInfo = false;
String title = "Log4J Log Messages";
/**
The <b>LocationInfo</b> 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.
<p>If you are embedding this layout within an {@link
org.apache.log4j.net.SMTPAppender} then make sure to set the
<b>LocationInfo</b> option of that appender as well.
*/
public void setLocationInfo(boolean flag) {
locationInfo = flag;
}
/**
Returns the current value of the <b>LocationInfo</b> option.
*/
public 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 Log Messages'.
*/
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".
*/
public String getContentType() {
return "text/html";
}
/**
No options to activate.
*/
public void activateOptions() {
}
public void format(java.io.Writer output, LoggingEvent event) throws java.io.IOException {
output.write(Layout.LINE_SEP + "<tr>" + Layout.LINE_SEP);
output.write("<td>");
output.write(Long.toString(event.timeStamp - LoggingEvent.getStartTime()));
output.write("</td>" + Layout.LINE_SEP);
output.write("<td title=\"" + event.getThreadName() + " thread\">");
Transform.escapeTags(event.getThreadName(), output);
output.write("</td>" + Layout.LINE_SEP);
output.write("<td title=\"Level\">");
if (event.getLevel().equals(Level.DEBUG)) {
output.write("<font color=\"#339933\">");
output.write(event.getLevel().toString());
output.write("</font>");
} else if (event.getLevel().isGreaterOrEqual(Level.WARN)) {
output.write("<font color=\"#993300\"><strong>");
output.write(event.getLevel().toString());
output.write("</strong></font>");
} else {
output.write(event.getLevel().toString());
}
output.write("</td>" + Layout.LINE_SEP);
output.write("<td title=\"" + event.getLoggerName() + " category\">");
output.write(event.getLoggerName());
output.write("</td>" + Layout.LINE_SEP);
if (locationInfo) {
LocationInfo locInfo = event.getLocationInformation();
output.write("<td>");
Transform.escapeTags(locInfo.getFileName(), output);
output.write(':');
output.write(locInfo.getLineNumber());
output.write("</td>" + Layout.LINE_SEP);
}
output.write("<td title=\"Message\">");
Transform.escapeTags(event.getRenderedMessage(), output);
output.write("</td>" + Layout.LINE_SEP);
output.write("</tr>" + Layout.LINE_SEP);
if (event.getNDC() != null) {
output.write(
"<tr><td bgcolor=\"#EEEEEE\" style=\"font-size : xx-small;\" colspan=\"6\" title=\"Nested Diagnostic Context\">");
Transform.escapeTags(event.getNDC(), output);
output.write("</td></tr>" + Layout.LINE_SEP);
}
String[] s = event.getThrowableStrRep();
if (s != null) {
output.write(
"<tr><td bgcolor=\"#993300\" style=\"color:White; font-size : xx-small;\" colspan=\"6\">");
appendThrowableAsHTML(s, output);
output.write("</td></tr>" + Layout.LINE_SEP);
}
}
void appendThrowableAsHTML(String[] s, Writer output) throws IOException {
if (s != null) {
int len = s.length;
if (len == 0) {
return;
}
Transform.escapeTags(s[0], output);
output.write(Layout.LINE_SEP);
for (int i = 1; i < len; i++) {
output.write(TRACE_PREFIX);
Transform.escapeTags(s[i], output);
output.write(Layout.LINE_SEP);
}
}
}
/**
Returns appropriate HTML headers.
*/
public String getHeader() {
StringBuffer sbuf = new StringBuffer();
sbuf.append(
"<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\" \"http://www.w3.org/TR/html4/loose.dtd\">"
+ Layout.LINE_SEP);
sbuf.append("<html>" + Layout.LINE_SEP);
sbuf.append("<head>" + Layout.LINE_SEP);
sbuf.append("<title>" + title + "</title>" + Layout.LINE_SEP);
sbuf.append("<style type=\"text/css\">" + Layout.LINE_SEP);
sbuf.append("<!--" + Layout.LINE_SEP);
sbuf.append(
"body, table {font-family: arial,sans-serif; font-size: x-small;}"
+ Layout.LINE_SEP);
sbuf.append(
"th {background: #336699; color: #FFFFFF; text-align: left;}"
+ Layout.LINE_SEP);
sbuf.append("-->" + Layout.LINE_SEP);
sbuf.append("</style>" + Layout.LINE_SEP);
sbuf.append("</head>" + Layout.LINE_SEP);
sbuf.append(
"<body bgcolor=\"#FFFFFF\" topmargin=\"6\" leftmargin=\"6\">"
+ Layout.LINE_SEP);
sbuf.append("<hr size=\"1\" noshade>" + Layout.LINE_SEP);
sbuf.append(
"Log session start time " + new java.util.Date() + "<br>"
+ Layout.LINE_SEP);
sbuf.append("<br>" + Layout.LINE_SEP);
sbuf.append(
"<table cellspacing=\"0\" cellpadding=\"4\" border=\"1\" bordercolor=\"#224466\" width=\"100%\">"
+ Layout.LINE_SEP);
sbuf.append("<tr>" + Layout.LINE_SEP);
sbuf.append("<th>Time</th>" + Layout.LINE_SEP);
sbuf.append("<th>Thread</th>" + Layout.LINE_SEP);
sbuf.append("<th>Level</th>" + Layout.LINE_SEP);
sbuf.append("<th>Category</th>" + Layout.LINE_SEP);
if (locationInfo) {
sbuf.append("<th>File:Line</th>" + Layout.LINE_SEP);
}
sbuf.append("<th>Message</th>" + Layout.LINE_SEP);
sbuf.append("</tr>" + Layout.LINE_SEP);
return sbuf.toString();
}
/**
Returns the appropriate HTML footers.
*/
public String getFooter() {
StringBuffer sbuf = new StringBuffer();
sbuf.append("</table>" + Layout.LINE_SEP);
sbuf.append("<br>" + Layout.LINE_SEP);
sbuf.append("</body></html>");
return sbuf.toString();
}
/**
The HTML layout handles the throwable contained in logging
events. Hence, this method return <code>false</code>. */
public boolean ignoresThrowable() {
return false;
}
}