X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=srcjar_unused%2Forg%2Fapache%2Flog4j%2FHTMLLayout.java;fp=srcjar_unused%2Forg%2Fapache%2Flog4j%2FHTMLLayout.java;h=164920829ac5c255cd1cde146b733c1cfb574c34;hb=2639d90e2b52d49cf586c0b602bc606033c9b8ae;hp=0000000000000000000000000000000000000000;hpb=aaead18c6acb21da4d63f3ad9f454d9eb410152f;p=jalview.git
diff --git a/srcjar_unused/org/apache/log4j/HTMLLayout.java b/srcjar_unused/org/apache/log4j/HTMLLayout.java
new file mode 100644
index 0000000..1649208
--- /dev/null
+++ b/srcjar_unused/org/apache/log4j/HTMLLayout.java
@@ -0,0 +1,268 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.log4j;
+
+import org.apache.log4j.spi.LoggingEvent;
+import org.apache.log4j.spi.LocationInfo;
+import org.apache.log4j.helpers.Transform;
+
+/**
+ * This layout outputs events in a HTML table.
+ *
+ * Appenders using this layout should have their encoding
+ * set to UTF-8 or UTF-16, otherwise events containing
+ * non ASCII characters could result in corrupted
+ * log files.
+ *
+ * @author Ceki Gülcü
+ */
+public class HTMLLayout extends Layout {
+
+ protected final int BUF_SIZE = 256;
+ protected final int MAX_CAPACITY = 1024;
+
+ static String TRACE_PREFIX = "
";
+
+ // output buffer appended to when format() is invoked
+ private StringBuffer sbuf = new StringBuffer(BUF_SIZE);
+
+ /**
+ A string constant used in naming the option for setting the the
+ location information flag. Current value of this string
+ constant is LocationInfo.
+
+
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 + near 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 Title. + */ + public static final String TITLE_OPTION = "Title"; + + // Print no location info by default + boolean locationInfo = false; + + String title = "Log4J Log Messages"; + + /** + 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 an {@link + org.apache.log4j.net.SMTPAppender} then make sure to set the + LocationInfo option of that appender as well. + */ + public + void setLocationInfo(boolean flag) { + locationInfo = flag; + } + + /** + Returns the current value of the LocationInfo option. + */ + public + boolean getLocationInfo() { + return locationInfo; + } + + /** + The Title option takes a String value. This option sets the + document title of the generated HTML document. + +
Defaults to 'Log4J Log Messages'. + */ + public + void setTitle(String title) { + this.title = title; + } + + /** + Returns the current value of the Title 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 + String format(LoggingEvent event) { + + if(sbuf.capacity() > MAX_CAPACITY) { + sbuf = new StringBuffer(BUF_SIZE); + } else { + sbuf.setLength(0); + } + + sbuf.append(Layout.LINE_SEP + "
Time | " + Layout.LINE_SEP); + sbuf.append("Thread | " + Layout.LINE_SEP); + sbuf.append("Level | " + Layout.LINE_SEP); + sbuf.append("Category | " + Layout.LINE_SEP); + if(locationInfo) { + sbuf.append("File:Line | " + Layout.LINE_SEP); + } + sbuf.append("Message | " + Layout.LINE_SEP); + sbuf.append("
---|
false
. */
+ public
+ boolean ignoresThrowable() {
+ return false;
+ }
+}