You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@logging.apache.org by rg...@apache.org on 2011/12/30 00:55:08 UTC
svn commit: r1225697 - in
/logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core:
layout/ lookup/ pattern/
Author: rgoers
Date: Thu Dec 29 23:55:08 2011
New Revision: 1225697
URL: http://svn.apache.org/viewvc?rev=1225697&view=rev
Log:
More checkstyle/javadoc fixes
Modified:
logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/layout/HTMLLayout.java
logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/layout/LayoutBase.java
logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/layout/PatternLayout.java
logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/layout/RFC5424Layout.java
logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/layout/SerializedLayout.java
logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/layout/SyslogLayout.java
logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/layout/XMLLayout.java
logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/lookup/ContextMapLookup.java
logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/lookup/Interpolator.java
logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/lookup/MapLookup.java
logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/lookup/StrLookup.java
logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/lookup/StrMatcher.java
logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/lookup/StrSubstitutor.java
logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/lookup/StructuredDataLookup.java
logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/lookup/SystemPropertiesLookup.java
logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/pattern/RegexReplacement.java
Modified: logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/layout/HTMLLayout.java
URL: http://svn.apache.org/viewvc/logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/layout/HTMLLayout.java?rev=1225697&r1=1225696&r2=1225697&view=diff
==============================================================================
--- logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/layout/HTMLLayout.java (original)
+++ logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/layout/HTMLLayout.java Thu Dec 29 23:55:08 2011
@@ -254,7 +254,7 @@ public final class HTMLLayout extends Ab
if (Charset.isSupported(charset)) {
c = Charset.forName(charset);
} else {
- logger.error("Charset " + charset + " is not supported for layout, using " + c.displayName());
+ LOGGER.error("Charset " + charset + " is not supported for layout, using " + c.displayName());
}
}
boolean info = locationInfo == null ? false : Boolean.valueOf(locationInfo);
Modified: logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/layout/LayoutBase.java
URL: http://svn.apache.org/viewvc/logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/layout/LayoutBase.java?rev=1225697&r1=1225696&r2=1225697&view=diff
==============================================================================
--- logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/layout/LayoutBase.java (original)
+++ logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/layout/LayoutBase.java Thu Dec 29 23:55:08 2011
@@ -24,14 +24,22 @@ import java.io.Serializable;
/**
* Base class for Layouts.
+ * @param <T> The Class that the Layout will format the LogEvent into.
*/
public abstract class LayoutBase<T extends Serializable> implements Layout<T> {
-
+ /**
+ * Allow subclasses access to the status logger without creating another instance.
+ */
+ protected static final Logger LOGGER = StatusLogger.getLogger();
+ /**
+ * The header to include when the stream is opened. May be null.
+ */
protected byte[] header;
+ /**
+ * The footer to add when the stream is closed. May be null.
+ */
protected byte[] footer;
- protected static final Logger logger = StatusLogger.getLogger();
-
/**
* Return the header, if one is available.
* @return A byte array containing the header.
Modified: logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/layout/PatternLayout.java
URL: http://svn.apache.org/viewvc/logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/layout/PatternLayout.java?rev=1225697&r1=1225696&r2=1225697&view=diff
==============================================================================
--- logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/layout/PatternLayout.java (original)
+++ logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/layout/PatternLayout.java Thu Dec 29 23:55:08 2011
@@ -1,20 +1,19 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
+ * 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 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
+ * 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.
+ * See the license for the specific language governing permissions and
+ * limitations under the license.
*/
-
package org.apache.logging.log4j.core.layout;
import org.apache.logging.log4j.core.LogEvent;
@@ -47,7 +46,7 @@ import java.util.List;
* See the Log4j Manual for details on the supported pattern converters.
*/
@Plugin(name = "PatternLayout", type = "Core", elementType = "layout", printObject = true)
-public class PatternLayout extends AbstractStringLayout {
+public final class PatternLayout extends AbstractStringLayout {
/**
* Default pattern string for log output. Currently set to the
* string <b>"%m%n"</b> which just prints the application supplied
@@ -69,13 +68,13 @@ public class PatternLayout extends Abstr
public static final String SIMPLE_CONVERSION_PATTERN =
"%d [%t] %p %c - %m%n";
+ private static final String KEY = "Converter";
+
/**
* Initial converter for pattern.
*/
private List<PatternConverter> converters;
- public static final String KEY = "Converter";
-
/**
* Conversion pattern.
*/
@@ -134,6 +133,7 @@ public class PatternLayout extends Abstr
* Formats a logging event to a writer.
*
* @param event logging event to be formatted.
+ * @return The event formatted as a String.
*/
public String formatAs(final LogEvent event) {
StringBuilder buf = new StringBuilder();
@@ -147,6 +147,11 @@ public class PatternLayout extends Abstr
return config == null ? str : config.getSubst().replace(event, str);
}
+ /**
+ * Create a PatternParser.
+ * @param config The Configuration.
+ * @return The PatternParser.
+ */
public static PatternParser createPatternParser(Configuration config) {
if (config == null) {
return new PatternParser(config, KEY, LogEventPatternConverter.class);
@@ -171,7 +176,7 @@ public class PatternLayout extends Abstr
* @param config The Configuration. Some Converters require access to the Interpolator.
* @param replace A Regex replacement String.
* @param charset The character set.
- * @return
+ * @return The PatternLayout.
*/
@PluginFactory
public static PatternLayout createLayout(@PluginAttr("pattern") String pattern,
@@ -183,7 +188,7 @@ public class PatternLayout extends Abstr
if (Charset.isSupported(charset)) {
c = Charset.forName(charset);
} else {
- logger.error("Charset " + charset + " is not supported for layout, using " + c.displayName());
+ LOGGER.error("Charset " + charset + " is not supported for layout, using " + c.displayName());
}
}
return new PatternLayout(config, replace, pattern == null ? DEFAULT_CONVERSION_PATTERN : pattern, c);
Modified: logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/layout/RFC5424Layout.java
URL: http://svn.apache.org/viewvc/logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/layout/RFC5424Layout.java?rev=1225697&r1=1225696&r2=1225697&view=diff
==============================================================================
--- logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/layout/RFC5424Layout.java (original)
+++ logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/layout/RFC5424Layout.java Thu Dec 29 23:55:08 2011
@@ -47,6 +47,21 @@ import java.util.TreeMap;
@Plugin(name = "RFC5424Layout", type = "Core", elementType = "layout", printObject = true)
public final class RFC5424Layout extends AbstractStringLayout {
+ /**
+ * Not a very good default - it is the Apache Software Foundation's enterprise number.
+ */
+ public static final int DEFAULT_ENTERPRISE_NUMBER = 18060;
+ /**
+ * The default event id.
+ */
+ public static final String DEFAULT_ID = "Audit";
+
+ private static final String DEFAULT_MDCID = "mdc";
+ private static final int TWO_DIGITS = 10;
+ private static final int THREE_DIGITS = 100;
+ private static final int MILLIS_PER_MINUTE = 60000;
+ private static final int MINUTES_PER_HOUR = 60;
+
private final Facility facility;
private final String defaultId;
private final Integer enterpriseNumber;
@@ -63,14 +78,9 @@ public final class RFC5424Layout extends
private final ListChecker noopChecker = new NoopChecker();
private final boolean includeNewLine;
- private static final String DEFAULT_MDCID = "mdc";
-
private long lastTimestamp = -1;
private String timestamppStr = null;
- // Not a very good default - it is the Apache Software Foundation's.
- public static final int DEFAULT_ENTERPRISE_NUMBER = 18060;
- public static final String DEFAULT_ID = "Audit";
private RFC5424Layout(Configuration config, Facility facility, String id, int ein, boolean includeMDC,
boolean includeNL, String mdcId, String appName, String messageId, String excludes,
@@ -129,12 +139,14 @@ public final class RFC5424Layout extends
mdcRequired = null;
}
this.checker = c != null ? c : noopChecker;
- String name = config == null ? null :config.getName();
+ String name = config == null ? null : config.getName();
configName = (name != null && name.length() > 0) ? name : null;
}
/**
* Formats a {@link org.apache.logging.log4j.core.LogEvent} in conformance with the RFC 5424 Syslog specification.
+ * @param event The LogEvent.
+ * @return The RFC 5424 String representation of the LogEvent.
*/
public String formatAs(final LogEvent event) {
Message msg = event.getMessage();
@@ -179,8 +191,7 @@ public final class RFC5424Layout extends
} else {
text = msg.getFormattedMessage();
}
- if (includeMDC)
- {
+ if (includeMDC) {
if (mdcRequired != null) {
checkRequired(event.getContextMap());
}
@@ -217,7 +228,7 @@ public final class RFC5424Layout extends
InetAddress addr = InetAddress.getLocalHost();
return addr.getHostName();
} catch (UnknownHostException uhe) {
- logger.error("Could not determine local host name", uhe);
+ LOGGER.error("Could not determine local host name", uhe);
return "UNKNOWN_LOCALHOST";
}
}
@@ -244,23 +255,23 @@ public final class RFC5424Layout extends
cal.setTimeInMillis(now);
buf.append(Integer.toString(cal.get(Calendar.YEAR)));
buf.append("-");
- pad(cal.get(Calendar.MONTH) + 1, 10, buf);
+ pad(cal.get(Calendar.MONTH) + 1, TWO_DIGITS, buf);
buf.append("-");
- pad(cal.get(Calendar.DAY_OF_MONTH), 10, buf);
+ pad(cal.get(Calendar.DAY_OF_MONTH), TWO_DIGITS, buf);
buf.append("T");
- pad(cal.get(Calendar.HOUR_OF_DAY), 10, buf);
+ pad(cal.get(Calendar.HOUR_OF_DAY), TWO_DIGITS, buf);
buf.append(":");
- pad(cal.get(Calendar.MINUTE), 10, buf);
+ pad(cal.get(Calendar.MINUTE), TWO_DIGITS, buf);
buf.append(":");
- pad(cal.get(Calendar.SECOND), 10, buf);
+ pad(cal.get(Calendar.SECOND), TWO_DIGITS, buf);
int millis = cal.get(Calendar.MILLISECOND);
if (millis != 0) {
buf.append(".");
- pad((int) ((float) millis / 10F), 100, buf);
+ pad((int) ((float) millis / 10F), THREE_DIGITS, buf);
}
- int tzmin = (cal.get(Calendar.ZONE_OFFSET) + cal.get(Calendar.DST_OFFSET)) / 60000;
+ int tzmin = (cal.get(Calendar.ZONE_OFFSET) + cal.get(Calendar.DST_OFFSET)) / MILLIS_PER_MINUTE;
if (tzmin == 0) {
buf.append("Z");
} else {
@@ -270,11 +281,11 @@ public final class RFC5424Layout extends
} else {
buf.append("+");
}
- int tzhour = tzmin / 60;
- tzmin -= tzhour * 60;
- pad(tzhour, 10, buf);
+ int tzhour = tzmin / MINUTES_PER_HOUR;
+ tzmin -= tzhour * MINUTES_PER_HOUR;
+ pad(tzhour, TWO_DIGITS, buf);
buf.append(":");
- pad(tzmin, 10, buf);
+ pad(tzmin, TWO_DIGITS, buf);
}
synchronized (this) {
if (last == lastTimestamp) {
@@ -290,16 +301,14 @@ public final class RFC5424Layout extends
if (val < max) {
buf.append("0");
}
- max = max / 10;
+ max = max / TWO_DIGITS;
}
buf.append(Integer.toString(val));
}
private void formatStructuredElement(StructuredDataId id, Map<String, String> data, StringBuilder sb,
- ListChecker checker)
- {
- if (id == null && defaultId == null)
- {
+ ListChecker checker) {
+ if (id == null && defaultId == null) {
return;
}
sb.append("[");
@@ -319,7 +328,7 @@ public final class RFC5424Layout extends
if (ein < 0) {
ein = enterpriseNumber;
}
- if (ein >=0) {
+ if (ein >= 0) {
sb.append("@").append(ein);
}
return sb.toString();
@@ -337,8 +346,7 @@ public final class RFC5424Layout extends
private void appendMap(Map<String, String> map, StringBuilder sb, ListChecker checker)
{
SortedMap<String, String> sorted = new TreeMap<String, String>(map);
- for (Map.Entry<String, String> entry : sorted.entrySet())
- {
+ for (Map.Entry<String, String> entry : sorted.entrySet()) {
if (checker.check(entry.getKey())) {
sb.append(" ");
sb.append(entry.getKey()).append("=\"").append(entry.getValue()).append("\"");
@@ -346,22 +354,34 @@ public final class RFC5424Layout extends
}
}
+ /**
+ * Interface used to check keys in a Map.
+ */
private interface ListChecker {
boolean check(String key);
}
+ /**
+ * Includes only the listed keys.
+ */
private class IncludeChecker implements ListChecker {
public boolean check(String key) {
return mdcIncludes.contains(key);
}
}
+ /**
+ * Excludes the listed keys.
+ */
private class ExcludeChecker implements ListChecker {
public boolean check(String key) {
return !mdcExcludes.contains(key);
}
}
+ /**
+ * Does nothing.
+ */
private class NoopChecker implements ListChecker {
public boolean check(String key) {
return true;
@@ -418,11 +438,11 @@ public final class RFC5424Layout extends
if (Charset.isSupported(charset)) {
c = Charset.forName(charset);
} else {
- logger.error("Charset " + charset + " is not supported for layout, using " + c.displayName());
+ LOGGER.error("Charset " + charset + " is not supported for layout, using " + c.displayName());
}
}
if (includes != null && excludes != null) {
- logger.error("mdcIncludes and mdcExcludes are mutually exclusive. Includes wil be ignored");
+ LOGGER.error("mdcIncludes and mdcExcludes are mutually exclusive. Includes wil be ignored");
includes = null;
}
Facility f = facility != null ? Facility.valueOf(facility.toUpperCase()) : Facility.LOCAL0;
@@ -433,7 +453,7 @@ public final class RFC5424Layout extends
mdcId = DEFAULT_MDCID;
}
- return new RFC5424Layout(config, f, id, enterpriseNumber, isMdc, includeNewLine, mdcId, appName, msgId, excludes,
- includes, required, c);
+ return new RFC5424Layout(config, f, id, enterpriseNumber, isMdc, includeNewLine, mdcId, appName, msgId,
+ excludes, includes, required, c);
}
}
Modified: logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/layout/SerializedLayout.java
URL: http://svn.apache.org/viewvc/logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/layout/SerializedLayout.java?rev=1225697&r1=1225696&r2=1225697&view=diff
==============================================================================
--- logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/layout/SerializedLayout.java (original)
+++ logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/layout/SerializedLayout.java Thu Dec 29 23:55:08 2011
@@ -29,7 +29,7 @@ import java.io.OutputStream;
* Format a LogEvent in its serialized form.
*/
@Plugin(name = "SerializedLayout", type = "Core", elementType = "layout", printObject = true)
-public class SerializedLayout extends LayoutBase<LogEvent> {
+public final class SerializedLayout extends LayoutBase<LogEvent> {
private static byte[] header;
@@ -40,7 +40,7 @@ public class SerializedLayout extends La
oos.close();
header = baos.toByteArray();
} catch (Exception ex) {
- logger.error("Unable to generate Object stream header", ex);
+ LOGGER.error("Unable to generate Object stream header", ex);
}
}
@@ -49,6 +49,8 @@ public class SerializedLayout extends La
/**
* Formats a {@link org.apache.logging.log4j.core.LogEvent} in conformance with the log4j.dtd.
+ * @param event The LogEvent.
+ * @return the formatted LogEvent.
*/
public byte[] format(final LogEvent event) {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
@@ -56,7 +58,7 @@ public class SerializedLayout extends La
ObjectOutputStream oos = new PrivateObjectOutputStream(baos);
oos.writeObject(event);
} catch (IOException ioe) {
- logger.error("Serialization of Logging Event failed.", ioe);
+ LOGGER.error("Serialization of Logging Event failed.", ioe);
}
return baos.toByteArray();
}
Modified: logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/layout/SyslogLayout.java
URL: http://svn.apache.org/viewvc/logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/layout/SyslogLayout.java?rev=1225697&r1=1225696&r2=1225697&view=diff
==============================================================================
--- logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/layout/SyslogLayout.java (original)
+++ logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/layout/SyslogLayout.java Thu Dec 29 23:55:08 2011
@@ -58,6 +58,8 @@ public class SyslogLayout extends Abstra
/**
* Formats a {@link org.apache.logging.log4j.core.LogEvent} in conformance with the log4j.dtd.
+ * @param event The LogEvent
+ * @return the event formatted as a String.
*/
public String formatAs(final LogEvent event) {
StringBuilder buf = new StringBuilder();
@@ -88,7 +90,7 @@ public class SyslogLayout extends Abstra
InetAddress addr = InetAddress.getLocalHost();
return addr.getHostName();
} catch (UnknownHostException uhe) {
- logger.error("Could not determine local host name", uhe);
+ LOGGER.error("Could not determine local host name", uhe);
return "UNKNOWN_LOCALHOST";
}
}
@@ -104,9 +106,9 @@ public class SyslogLayout extends Abstra
/**
* Create a SyslogLayout.
- * @param facility
- * @param includeNL
- * @param charset
+ * @param facility The Facility is used to try to classify the message.
+ * @param includeNL If true a newline will be appended to the result.
+ * @param charset The character set.
* @return A SyslogLayout.
*/
@PluginFactory
@@ -119,7 +121,7 @@ public class SyslogLayout extends Abstra
if (Charset.isSupported(charset)) {
c = Charset.forName(charset);
} else {
- logger.error("Charset " + charset + " is not supported for layout, using " + c.displayName());
+ LOGGER.error("Charset " + charset + " is not supported for layout, using " + c.displayName());
}
}
boolean includeNewLine = includeNL == null ? false : Boolean.valueOf(includeNL);
Modified: logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/layout/XMLLayout.java
URL: http://svn.apache.org/viewvc/logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/layout/XMLLayout.java?rev=1225697&r1=1225696&r2=1225697&view=diff
==============================================================================
--- logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/layout/XMLLayout.java (original)
+++ logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/layout/XMLLayout.java Thu Dec 29 23:55:08 2011
@@ -71,12 +71,12 @@ import org.apache.logging.log4j.core.Log
@Plugin(name = "XMLLayout", type = "Core", elementType = "layout", printObject = true)
public class XMLLayout extends AbstractStringLayout {
+ private static final int DEFAULT_SIZE = 256;
+
private final boolean locationInfo;
private final boolean properties;
private final boolean complete;
- protected static final int DEFAULT_SIZE = 256;
-
protected XMLLayout(boolean locationInfo, boolean properties, boolean complete, Charset charset) {
super(charset);
this.locationInfo = locationInfo;
@@ -86,6 +86,8 @@ public class XMLLayout extends AbstractS
/**
* Formats a {@link org.apache.logging.log4j.core.LogEvent} in conformance with the log4j.dtd.
+ * @param event The LogEvent.
+ * @return The XML representation of the LogEvent.
*/
public String formatAs(final LogEvent event) {
StringBuilder buf = new StringBuilder(DEFAULT_SIZE);
@@ -161,6 +163,7 @@ public class XMLLayout extends AbstractS
/**
* Returns appropriate XML headers.
+ * @return a byte array containing the header.
*/
@Override
public byte[] getHeader() {
@@ -176,6 +179,7 @@ public class XMLLayout extends AbstractS
/**
* Returns appropriate XML headers.
+ * @return a byte array containing the footer.
*/
@Override
public byte[] getFooter() {
@@ -192,18 +196,19 @@ public class XMLLayout extends AbstractS
PrintWriter pw = new PrintWriter(sw);
try {
throwable.printStackTrace(pw);
- } catch(RuntimeException ex) {
+ } catch (RuntimeException ex) {
+ // Ignore any exceptions.
}
pw.flush();
LineNumberReader reader = new LineNumberReader(new StringReader(sw.toString()));
ArrayList<String> lines = new ArrayList<String>();
try {
String line = reader.readLine();
- while(line != null) {
+ while (line != null) {
lines.add(line);
line = reader.readLine();
}
- } catch(IOException ex) {
+ } catch (IOException ex) {
if (ex instanceof InterruptedIOException) {
Thread.currentThread().interrupt();
}
@@ -230,7 +235,7 @@ public class XMLLayout extends AbstractS
if (Charset.isSupported(charset)) {
c = Charset.forName(charset);
} else {
- logger.error("Charset " + charset + " is not supported for layout, using " + c.displayName());
+ LOGGER.error("Charset " + charset + " is not supported for layout, using " + c.displayName());
}
}
boolean info = locationInfo == null ? false : Boolean.valueOf(locationInfo);
Modified: logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/lookup/ContextMapLookup.java
URL: http://svn.apache.org/viewvc/logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/lookup/ContextMapLookup.java?rev=1225697&r1=1225696&r2=1225697&view=diff
==============================================================================
--- logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/lookup/ContextMapLookup.java (original)
+++ logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/lookup/ContextMapLookup.java Thu Dec 29 23:55:08 2011
@@ -21,7 +21,7 @@ import org.apache.logging.log4j.core.Log
import org.apache.logging.log4j.core.config.plugins.Plugin;
/**
- * Looks up keys from system properties
+ * Looks up keys from system properties.
*/
@Plugin(name = "ctx", type = "Lookup")
public class ContextMapLookup implements StrLookup {
Modified: logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/lookup/Interpolator.java
URL: http://svn.apache.org/viewvc/logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/lookup/Interpolator.java?rev=1225697&r1=1225696&r2=1225697&view=diff
==============================================================================
--- logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/lookup/Interpolator.java (original)
+++ logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/lookup/Interpolator.java Thu Dec 29 23:55:08 2011
@@ -30,7 +30,7 @@ import java.util.Map;
*/
public class Interpolator implements StrLookup {
- protected final static Logger logger = StatusLogger.getLogger();
+ private static final Logger LOGGER = StatusLogger.getLogger();
/** Constant for the prefix separator. */
private static final char PREFIX_SEPARATOR = ':';
@@ -50,7 +50,7 @@ public class Interpolator implements Str
try {
lookups.put(entry.getKey(), clazz.newInstance());
} catch (Exception ex) {
- logger.error("Unable to create Lookup for " + entry.getKey(), ex);
+ LOGGER.error("Unable to create Lookup for " + entry.getKey(), ex);
}
}
}
@@ -67,8 +67,7 @@ public class Interpolator implements Str
* @return the value of this variable or <b>null</b> if it cannot be
* resolved
*/
- public String lookup(String var)
- {
+ public String lookup(String var) {
return lookup(null, var);
}
@@ -85,16 +84,13 @@ public class Interpolator implements Str
* @return the value of this variable or <b>null</b> if it cannot be
* resolved
*/
- public String lookup(LogEvent event, String var)
- {
- if (var == null)
- {
+ public String lookup(LogEvent event, String var) {
+ if (var == null) {
return null;
}
int prefixPos = var.indexOf(PREFIX_SEPARATOR);
- if (prefixPos >= 0)
- {
+ if (prefixPos >= 0) {
String prefix = var.substring(0, prefixPos);
String name = var.substring(prefixPos + 1);
StrLookup lookup = lookups.get(prefix);
@@ -103,8 +99,7 @@ public class Interpolator implements Str
value = event == null ? lookup.lookup(name) : lookup.lookup(event, name);
}
- if (value != null)
- {
+ if (value != null) {
return value;
}
var = var.substring(prefixPos);
Modified: logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/lookup/MapLookup.java
URL: http://svn.apache.org/viewvc/logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/lookup/MapLookup.java?rev=1225697&r1=1225696&r2=1225697&view=diff
==============================================================================
--- logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/lookup/MapLookup.java (original)
+++ logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/lookup/MapLookup.java Thu Dec 29 23:55:08 2011
@@ -24,6 +24,7 @@ import java.util.Map;
/**
* The basis for a lookup based on a Map.
+ * @param <V> The type of object contained in the Map.
*/
@Plugin(name = "map", type = "Lookup")
public class MapLookup<V> implements StrLookup<V> {
Modified: logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/lookup/StrLookup.java
URL: http://svn.apache.org/viewvc/logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/lookup/StrLookup.java?rev=1225697&r1=1225696&r2=1225697&view=diff
==============================================================================
--- logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/lookup/StrLookup.java (original)
+++ logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/lookup/StrLookup.java Thu Dec 29 23:55:08 2011
@@ -33,6 +33,8 @@ import org.apache.logging.log4j.core.Log
*
* @author Apache Software Foundation
* @version $Id$
+ *
+ * @param <V> The type of the value that is being queried.
*/
public interface StrLookup<V> {
/**
@@ -58,7 +60,7 @@ public interface StrLookup<V> {
* @param key the key to be looked up, may be null
* @return the matching value, null if no match
*/
- public String lookup(String key);
+ String lookup(String key);
/**
* Looks up a String key to a String value possibly using the current LogEvent.
@@ -84,5 +86,5 @@ public interface StrLookup<V> {
* @param key the key to be looked up, may be null
* @return the matching value, null if no match
*/
- public String lookup(LogEvent event, String key);
-}
\ No newline at end of file
+ String lookup(LogEvent event, String key);
+}
Modified: logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/lookup/StrMatcher.java
URL: http://svn.apache.org/viewvc/logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/lookup/StrMatcher.java?rev=1225697&r1=1225696&r2=1225697&view=diff
==============================================================================
--- logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/lookup/StrMatcher.java (original)
+++ logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/lookup/StrMatcher.java Thu Dec 29 23:55:08 2011
@@ -65,7 +65,11 @@ public abstract class StrMatcher {
*/
private static final StrMatcher NONE_MATCHER = new NoMatcher();
- // -----------------------------------------------------------------------
+ /**
+ * Constructor.
+ */
+ protected StrMatcher() {
+ }
/**
* Returns a matcher which matches the comma character.
@@ -204,14 +208,6 @@ public abstract class StrMatcher {
return new StringMatcher(str);
}
- //-----------------------------------------------------------------------
- /**
- * Constructor.
- */
- protected StrMatcher() {
- super();
- }
-
/**
* Returns the number of matching characters, zero for no match.
* <p>
@@ -276,7 +272,7 @@ public abstract class StrMatcher {
*
* @param chars the characters to match, must not be null
*/
- CharSetMatcher(char chars[]) {
+ CharSetMatcher(char[] chars) {
super();
this.chars = chars.clone();
Arrays.sort(this.chars);
Modified: logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/lookup/StrSubstitutor.java
URL: http://svn.apache.org/viewvc/logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/lookup/StrSubstitutor.java?rev=1225697&r1=1225696&r2=1225697&view=diff
==============================================================================
--- logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/lookup/StrSubstitutor.java (original)
+++ logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/lookup/StrSubstitutor.java Thu Dec 29 23:55:08 2011
@@ -116,6 +116,8 @@ public class StrSubstitutor {
*/
public static final StrMatcher DEFAULT_SUFFIX = StrMatcher.stringMatcher("}");
+ private static final int BUF_SIZE = 256;
+
/**
* Stores the escape character.
*/
@@ -139,70 +141,17 @@ public class StrSubstitutor {
//-----------------------------------------------------------------------
/**
- * Replaces all the occurrences of variables in the given source object with
- * their matching values from the map.
- *
- * @param source the source text containing the variables to substitute, null returns null
- * @param valueMap the map with the values, may be null
- * @return the result of the replace operation
- */
- public static <V> String replace(Object source, Map<String, V> valueMap) {
- return new StrSubstitutor(valueMap).replace(source);
- }
-
- /**
- * Replaces all the occurrences of variables in the given source object with
- * their matching values from the map. This method allows to specifiy a
- * custom variable prefix and suffix
- *
- * @param source the source text containing the variables to substitute, null returns null
- * @param valueMap the map with the values, may be null
- * @param prefix the prefix of variables, not null
- * @param suffix the suffix of variables, not null
- * @return the result of the replace operation
- * @throws IllegalArgumentException if the prefix or suffix is null
- */
- public static <V> String replace(Object source, Map<String, V> valueMap, String prefix, String suffix) {
- return new StrSubstitutor(valueMap, prefix, suffix).replace(source);
- }
-
- /**
- * Replaces all the occurrences of variables in the given source object with their matching
- * values from the properties.
- *
- * @param source the source text containing the variables to substitute, null returns null
- * @param valueProperties the properties with values, may be null
- * @return the result of the replace operation
- */
- public static String replace(Object source, Properties valueProperties)
- {
- if (valueProperties == null) {
- return source.toString();
- }
- Map<String,String> valueMap = new HashMap<String,String>();
- Enumeration<?> propNames = valueProperties.propertyNames();
- while (propNames.hasMoreElements())
- {
- String propName = (String)propNames.nextElement();
- String propValue = valueProperties.getProperty(propName);
- valueMap.put(propName, propValue);
- }
- return StrSubstitutor.replace(source, valueMap);
- }
-
- //-----------------------------------------------------------------------
- /**
* Creates a new instance with defaults for variable prefix and suffix
* and the escaping character.
*/
public StrSubstitutor() {
- this((StrLookup<?>) null, DEFAULT_PREFIX, DEFAULT_SUFFIX, DEFAULT_ESCAPE);
+ this(null, DEFAULT_PREFIX, DEFAULT_SUFFIX, DEFAULT_ESCAPE);
}
-
/**
* Creates a new instance and initializes it. Uses defaults for variable
* prefix and suffix and the escaping character.
*
+ * @param <V> The type of object contained in the Map.
* @param valueMap the map with the variables' values, may be null
*/
public <V> StrSubstitutor(Map<String, V> valueMap) {
@@ -212,6 +161,7 @@ public class StrSubstitutor {
/**
* Creates a new instance and initializes it. Uses a default escaping character.
*
+ * @param <V> The type of object contained in the Map.
* @param valueMap the map with the variables' values, may be null
* @param prefix the prefix for variables, not null
* @param suffix the suffix for variables, not null
@@ -224,6 +174,7 @@ public class StrSubstitutor {
/**
* Creates a new instance and initializes it.
*
+ * @param <V> The type of object contained in the Map.
* @param valueMap the map with the variables' values, may be null
* @param prefix the prefix for variables, not null
* @param suffix the suffix for variables, not null
@@ -268,13 +219,65 @@ public class StrSubstitutor {
* @param escape the escape character
* @throws IllegalArgumentException if the prefix or suffix is null
*/
- public StrSubstitutor(
- StrLookup<?> variableResolver, StrMatcher prefixMatcher, StrMatcher suffixMatcher, char escape) {
+ public StrSubstitutor(StrLookup<?> variableResolver, StrMatcher prefixMatcher, StrMatcher suffixMatcher,
+ char escape) {
this.setVariableResolver(variableResolver);
this.setVariablePrefixMatcher(prefixMatcher);
this.setVariableSuffixMatcher(suffixMatcher);
this.setEscapeChar(escape);
}
+ //-----------------------------------------------------------------------
+ /**
+ * Replaces all the occurrences of variables in the given source object with
+ * their matching values from the map.
+ *
+ * @param <V> The type of object contained in the Map.
+ * @param source the source text containing the variables to substitute, null returns null
+ * @param valueMap the map with the values, may be null
+ * @return the result of the replace operation
+ */
+ public static <V> String replace(Object source, Map<String, V> valueMap) {
+ return new StrSubstitutor(valueMap).replace(source);
+ }
+
+ /**
+ * Replaces all the occurrences of variables in the given source object with
+ * their matching values from the map. This method allows to specifiy a
+ * custom variable prefix and suffix
+ *
+ * @param <V> The type of object contained in the Map.
+ * @param source the source text containing the variables to substitute, null returns null
+ * @param valueMap the map with the values, may be null
+ * @param prefix the prefix of variables, not null
+ * @param suffix the suffix of variables, not null
+ * @return the result of the replace operation
+ * @throws IllegalArgumentException if the prefix or suffix is null
+ */
+ public static <V> String replace(Object source, Map<String, V> valueMap, String prefix, String suffix) {
+ return new StrSubstitutor(valueMap, prefix, suffix).replace(source);
+ }
+
+ /**
+ * Replaces all the occurrences of variables in the given source object with their matching
+ * values from the properties.
+ *
+ * @param source the source text containing the variables to substitute, null returns null
+ * @param valueProperties the properties with values, may be null
+ * @return the result of the replace operation
+ */
+ public static String replace(Object source, Properties valueProperties) {
+ if (valueProperties == null) {
+ return source.toString();
+ }
+ Map<String, String> valueMap = new HashMap<String, String>();
+ Enumeration<?> propNames = valueProperties.propertyNames();
+ while (propNames.hasMoreElements()) {
+ String propName = (String) propNames.nextElement();
+ String propValue = valueProperties.getProperty(propName);
+ valueMap.put(propName, propValue);
+ }
+ return StrSubstitutor.replace(source, valueMap);
+ }
//-----------------------------------------------------------------------
/**
@@ -301,7 +304,7 @@ public class StrSubstitutor {
return null;
}
StringBuilder buf = new StringBuilder(source);
- if (substitute(event, buf, 0, source.length()) == false) {
+ if (!substitute(event, buf, 0, source.length())) {
return source;
}
return buf.toString();
@@ -341,7 +344,7 @@ public class StrSubstitutor {
return null;
}
StringBuilder buf = new StringBuilder(length).append(source, offset, length);
- if (substitute(event, buf, 0, length) == false) {
+ if (!substitute(event, buf, 0, length)) {
return source.substring(offset, offset + length);
}
return buf.toString();
@@ -510,8 +513,9 @@ public class StrSubstitutor {
* from the resolver using the given source builder as a template.
* The builder is not altered by this method.
*
- * @param source the builder to use as a template, not changed, null returns null
- * @return the result of the replace operation
+ * @param event The LogEvent.
+ * @param source the builder to use as a template, not changed, null returns null.
+ * @return the result of the replace operation.
*/
public String replace(LogEvent event, StringBuilder source) {
if (source == null) {
@@ -644,7 +648,7 @@ public class StrSubstitutor {
return false;
}
StringBuilder buf = new StringBuilder(length).append(source, offset, length);
- if (substitute(event, buf, 0, length) == false) {
+ if (!substitute(event, buf, 0, length)) {
return false;
}
source.replace(offset, offset + length, buf.toString());
@@ -862,10 +866,10 @@ public class StrSubstitutor {
* @param priorVariables the list of prior variables
*/
private void checkCyclicSubstitution(String varName, List<String> priorVariables) {
- if (priorVariables.contains(varName) == false) {
+ if (!priorVariables.contains(varName)) {
return;
}
- StringBuilder buf = new StringBuilder(256);
+ StringBuilder buf = new StringBuilder(BUF_SIZE);
buf.append("Infinite loop in property interpolation of ");
buf.append(priorVariables.remove(0));
buf.append(": ");
@@ -1078,7 +1082,6 @@ public class StrSubstitutor {
* Returns a flag whether substitution is done in variable names.
*
* @return the substitution in variable names flag
- * @since 3.0
*/
public boolean isEnableSubstitutionInVariables() {
return enableSubstitutionInVariables;
@@ -1091,10 +1094,8 @@ public class StrSubstitutor {
* <code>${jre-${java.version}}</code>. The default value is <b>false</b>.
*
* @param enableSubstitutionInVariables the new value of the flag
- * @since 3.0
*/
- public void setEnableSubstitutionInVariables(
- boolean enableSubstitutionInVariables) {
+ public void setEnableSubstitutionInVariables(boolean enableSubstitutionInVariables) {
this.enableSubstitutionInVariables = enableSubstitutionInVariables;
}
@@ -1109,9 +1110,9 @@ public class StrSubstitutor {
* not before the first or after the last.
* Appending a null iterable will have no effect..
*
+ * @param sb StringBuilder that contains the String being constructed.
* @param iterable the iterable to append
* @param separator the separator to use, null means no separator
- * @return this, to enable chaining
*/
public void appendWithSeparators(StringBuilder sb, Iterable<?> iterable, String separator) {
if (iterable != null) {
@@ -1126,7 +1127,8 @@ public class StrSubstitutor {
}
}
+ @Override
public String toString() {
return "StrSubstitutor(" + variableResolver.toString() + ")";
}
-}
\ No newline at end of file
+}
Modified: logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/lookup/StructuredDataLookup.java
URL: http://svn.apache.org/viewvc/logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/lookup/StructuredDataLookup.java?rev=1225697&r1=1225696&r2=1225697&view=diff
==============================================================================
--- logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/lookup/StructuredDataLookup.java (original)
+++ logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/lookup/StructuredDataLookup.java Thu Dec 29 23:55:08 2011
@@ -21,15 +21,26 @@ import org.apache.logging.log4j.core.con
import org.apache.logging.log4j.message.StructuredDataMessage;
/**
- * Looks up keys from system properties
+ * Looks up keys from system properties.
*/
@Plugin(name = "sd", type = "Lookup")
public class StructuredDataLookup implements StrLookup {
+ /**
+ * Lookup the value for the key.
+ * @param key the key to be looked up, may be null
+ * @return The value for the key.
+ */
public String lookup(String key) {
return null;
}
+ /**
+ * Lookup the value for the key using the data in the LogEvent.
+ * @param event The current LogEvent.
+ * @param key the key to be looked up, may be null
+ * @return The value associated with the key.
+ */
public String lookup(LogEvent event, String key) {
if (event == null || !(event.getMessage() instanceof StructuredDataMessage)) {
return null;
Modified: logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/lookup/SystemPropertiesLookup.java
URL: http://svn.apache.org/viewvc/logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/lookup/SystemPropertiesLookup.java?rev=1225697&r1=1225696&r2=1225697&view=diff
==============================================================================
--- logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/lookup/SystemPropertiesLookup.java (original)
+++ logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/lookup/SystemPropertiesLookup.java Thu Dec 29 23:55:08 2011
@@ -20,15 +20,26 @@ import org.apache.logging.log4j.core.Log
import org.apache.logging.log4j.core.config.plugins.Plugin;
/**
- * Looks up keys from system properties
+ * Looks up keys from system properties.
*/
@Plugin(name = "sys", type = "Lookup")
public class SystemPropertiesLookup implements StrLookup {
+ /**
+ * Lookup the value for the key.
+ * @param key the key to be looked up, may be null
+ * @return The value for the key.
+ */
public String lookup(String key) {
return System.getProperty(key);
}
+ /**
+ * Lookup the value for the key using the data in the LogEvent.
+ * @param event The current LogEvent.
+ * @param key the key to be looked up, may be null
+ * @return The value associated with the key.
+ */
public String lookup(LogEvent event, String key) {
return System.getProperty(key);
}
Modified: logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/pattern/RegexReplacement.java
URL: http://svn.apache.org/viewvc/logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/pattern/RegexReplacement.java?rev=1225697&r1=1225696&r2=1225697&view=diff
==============================================================================
--- logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/pattern/RegexReplacement.java (original)
+++ logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/pattern/RegexReplacement.java Thu Dec 29 23:55:08 2011
@@ -40,7 +40,8 @@ public final class RegexReplacement {
/**
* Private constructor.
*
- * @param options options, may be null.
+ * @param pattern The Pattern.
+ * @param substitution The substitution String.
*/
private RegexReplacement(Pattern pattern, String substitution) {
this.pattern = pattern;
@@ -48,7 +49,9 @@ public final class RegexReplacement {
}
/**
- * {@inheritDoc}
+ * Perform the replacement.
+ * @param msg The String to match against.
+ * @return the replacement String.
*/
public String format(String msg) {
return pattern.matcher(msg).replaceAll(substitution);