You are viewing a plain text version of this content. The canonical link for it is here.
Posted to log4j-dev@logging.apache.org by ca...@apache.org on 2007/04/11 23:04:40 UTC
svn commit: r527671 - in /logging/log4j/trunk/src/java/org/apache/log4j: ./
helpers/ spi/
Author: carnold
Date: Wed Apr 11 14:04:39 2007
New Revision: 527671
URL: http://svn.apache.org/viewvc?view=rev&rev=527671
Log:
Bug 42092: Checkstyle fixes in o.a.l.spi, .helpers, and o.a.l.ULogger
Modified:
logging/log4j/trunk/src/java/org/apache/log4j/ULogger.java
logging/log4j/trunk/src/java/org/apache/log4j/helpers/MessageFormatter.java
logging/log4j/trunk/src/java/org/apache/log4j/spi/Component.java
logging/log4j/trunk/src/java/org/apache/log4j/spi/ComponentBase.java
logging/log4j/trunk/src/java/org/apache/log4j/spi/ErrorItem.java
logging/log4j/trunk/src/java/org/apache/log4j/spi/LoggerEventListener.java
logging/log4j/trunk/src/java/org/apache/log4j/spi/LoggerRepositoryEventListener.java
logging/log4j/trunk/src/java/org/apache/log4j/spi/LoggerRepositoryEx.java
logging/log4j/trunk/src/java/org/apache/log4j/spi/NOPULogger.java
logging/log4j/trunk/src/java/org/apache/log4j/spi/SimpleULogger.java
logging/log4j/trunk/src/java/org/apache/log4j/spi/Thresholdable.java
Modified: logging/log4j/trunk/src/java/org/apache/log4j/ULogger.java
URL: http://svn.apache.org/viewvc/logging/log4j/trunk/src/java/org/apache/log4j/ULogger.java?view=diff&rev=527671&r1=527670&r2=527671
==============================================================================
--- logging/log4j/trunk/src/java/org/apache/log4j/ULogger.java (original)
+++ logging/log4j/trunk/src/java/org/apache/log4j/ULogger.java Wed Apr 11 14:04:39 2007
@@ -20,7 +20,7 @@
/**
* A proxy for org.slf4j.ULogger. In slf4j implementing builds, this
* interface will extend org.slf4j.ULogger and add no additional methods.
- *
+ *
* @author Ceki Gülcü
* @author Curt Arnold
*/
@@ -31,59 +31,172 @@
* Is the logger instance enabled for the DEBUG level?
* @return true if debug is enabled.
*/
- public boolean isDebugEnabled();
-//
-
+ boolean isDebugEnabled();
+
/**
- * Log a message object with the DEBUG level.
+ * Log a message object with the DEBUG level.
* @param msg - the message object to be logged
*/
- public void debug(Object msg);
-
-
+ void debug(Object msg);
+
+
/**
- * Log a parameterized message object at the DEBUG level.
- *
+ * Log a parameterized message object at the DEBUG level.
+ *
* <p>This form is useful in avoiding the superflous object creation
* problem when invoking this method while it is disabled.
* </p>
* @param parameterizedMsg - the parameterized message object
- * @param param1 - the parameter
+ * @param param1 - the parameter
*/
- public void debug(Object parameterizedMsg, Object param1);
-
+ void debug(Object parameterizedMsg, Object param1);
+
/**
- * Log a parameterized message object at the DEBUG level.
- *
+ * Log a parameterized message object at the DEBUG level.
+ *
* <p>This form is useful in avoiding the superflous object creation
* problem when invoking this method while it is disabled.
* </p>
* @param parameterizedMsg - the parameterized message object
- * @param param1 - the first parameter
- * @param param2 - the second parameter
+ * @param param1 - the first parameter
+ * @param param2 - the second parameter
*/
- public void debug(String parameterizedMsg, Object param1, Object param2);
- public void debug(Object msg, Throwable t);
-
-
- public boolean isInfoEnabled();
- public void info(Object msg);
- public void info(Object parameterizedMsg, Object param1);
- public void info(String parameterizedMsg, Object param1, Object param2);
- public void info(Object msg, Throwable t);
-
-
- public boolean isWarnEnabled();
- public void warn(Object msg);
- public void warn(Object parameterizedMsg, Object param1);
- public void warn(String parameterizedMsg, Object param1, Object param2);
- public void warn(Object msg, Throwable t);
-
-
- public boolean isErrorEnabled();
- public void error(Object msg);
- public void error(Object parameterizedMsg, Object param1);
- public void error(String parameterizedMsg, Object param1, Object param2);
- public void error(Object msg, Throwable t);
+ void debug(String parameterizedMsg, Object param1, Object param2);
+ /**
+ * Log a message object with the <code>DEBUG</code> level including the
+ * stack trace of the {@link Throwable}<code>t</code> passed as parameter.
+ *
+ *
+ * @param msg the message object to log.
+ * @param t the exception to log, including its stack trace.
+ */
+ void debug(Object msg, Throwable t);
+
+
+ /**
+ * Is the logger instance enabled for the INFO level?
+ * @return true if debug is enabled.
+ */
+ boolean isInfoEnabled();
+ /**
+ * Log a message object with the INFO level.
+ * @param msg - the message object to be logged
+ */
+ void info(Object msg);
+ /**
+ * Log a parameterized message object at the INFO level.
+ *
+ * <p>This form is useful in avoiding the superflous object creation
+ * problem when invoking this method while it is disabled.
+ * </p>
+ * @param parameterizedMsg - the parameterized message object
+ * @param param1 - the parameter
+ */
+ void info(Object parameterizedMsg, Object param1);
+ /**
+ * Log a parameterized message object at the INFO level.
+ *
+ * <p>This form is useful in avoiding the superflous object creation
+ * problem when invoking this method while it is disabled.
+ * </p>
+ * @param parameterizedMsg - the parameterized message object
+ * @param param1 - the first parameter
+ * @param param2 - the second parameter
+ */
+ void info(String parameterizedMsg, Object param1, Object param2);
+ /**
+ * Log a message object with the <code>INFO</code> level including the
+ * stack trace of the {@link Throwable}<code>t</code> passed as parameter.
+ *
+ *
+ * @param msg the message object to log.
+ * @param t the exception to log, including its stack trace.
+ */
+ void info(Object msg, Throwable t);
+
+
+ /**
+ * Is the logger instance enabled for the WARN level?
+ * @return true if debug is enabled.
+ */
+ boolean isWarnEnabled();
+ /**
+ * Log a message object with the WARN level.
+ * @param msg - the message object to be logged
+ */
+ void warn(Object msg);
+ /**
+ * Log a parameterized message object at the WARN level.
+ *
+ * <p>This form is useful in avoiding the superflous object creation
+ * problem when invoking this method while it is disabled.
+ * </p>
+ * @param parameterizedMsg - the parameterized message object
+ * @param param1 - the parameter
+ */
+ void warn(Object parameterizedMsg, Object param1);
+ /**
+ * Log a parameterized message object at the WARN level.
+ *
+ * <p>This form is useful in avoiding the superflous object creation
+ * problem when invoking this method while it is disabled.
+ * </p>
+ * @param parameterizedMsg - the parameterized message object
+ * @param param1 - the first parameter
+ * @param param2 - the second parameter
+ */
+ void warn(String parameterizedMsg, Object param1, Object param2);
+ /**
+ * Log a message object with the <code>WARN</code> level including the
+ * stack trace of the {@link Throwable}<code>t</code> passed as parameter.
+ *
+ *
+ * @param msg the message object to log.
+ * @param t the exception to log, including its stack trace.
+ */
+ void warn(Object msg, Throwable t);
+
+
+ /**
+ * Is the logger instance enabled for the ERROR level?
+ * @return true if debug is enabled.
+ */
+ boolean isErrorEnabled();
+ /**
+ * Log a message object with the ERROR level.
+ * @param msg - the message object to be logged
+ */
+ void error(Object msg);
+ /**
+ * Log a parameterized message object at the ERROR level.
+ *
+ * <p>This form is useful in avoiding the superflous object creation
+ * problem when invoking this method while it is disabled.
+ * </p>
+ * @param parameterizedMsg - the parameterized message object
+ * @param param1 - the parameter
+ */
+ void error(Object parameterizedMsg, Object param1);
+ /**
+ * Log a parameterized message object at the ERROR level.
+ *
+ * <p>This form is useful in avoiding the superflous object creation
+ * problem when invoking this method while it is disabled.
+ * </p>
+ * @param parameterizedMsg - the parameterized message object
+ * @param param1 - the first parameter
+ * @param param2 - the second parameter
+ */
+ void error(String parameterizedMsg, Object param1, Object param2);
+
+ /**
+ * Log a message object with the <code>ERROR</code> level including the
+ * stack trace of the {@link Throwable}<code>t</code> passed as parameter.
+ *
+ *
+ * @param msg the message object to log.
+ * @param t the exception to log, including its stack trace.
+ */
+ void error(Object msg, Throwable t);
}
Modified: logging/log4j/trunk/src/java/org/apache/log4j/helpers/MessageFormatter.java
URL: http://svn.apache.org/viewvc/logging/log4j/trunk/src/java/org/apache/log4j/helpers/MessageFormatter.java?view=diff&rev=527671&r1=527670&r2=527671
==============================================================================
--- logging/log4j/trunk/src/java/org/apache/log4j/helpers/MessageFormatter.java (original)
+++ logging/log4j/trunk/src/java/org/apache/log4j/helpers/MessageFormatter.java Wed Apr 11 14:04:39 2007
@@ -18,109 +18,136 @@
/**
- * Formats messages according to very simple rules.
- * See {@link #format(String, Object)} and
- * {@link #format(String, Object, Object)} for more details.
+ * Formats messages according to very simple rules.
+ * See {@link #format(String,Object)} and
+ * {@link #format(String,Object,Object)} for more details.
*
* @author Ceki Gülcü
*/
-public class MessageFormatter {
- static final char DELIM_START = '{';
- static final char DELIM_STOP = '}';
-
- /**
- * Performs single argument substitution for the 'messagePattern' passed as
- * parameter.
- * <p>
- * For example, <code>MessageFormatter.format("Hi {}.", "there");</code> will
- * return the string "Hi there.".
- * <p>
- * The {} pair is called the formatting element. It serves to designate the
- * location where the argument needs to be inserted within the pattern.
- *
- * @param messagePattern The message pattern which will be parsed and formatted
- * @param argument The argument to be inserted instead of the formatting element
- * @return The formatted message
- */
- public static String format(String messagePattern, Object argument) {
- int j = messagePattern.indexOf(DELIM_START);
- int len = messagePattern.length();
- char escape = 'x';
-
- // if there are no { characters or { is the last character of the messsage
- // then we just return messagePattern
- if (j == -1 || (j+1 == len)) {
- return messagePattern;
- } else {
- if(j+1 == len) {
- }
-
- char delimStop = messagePattern.charAt(j + 1);
- if (j > 0) {
- escape = messagePattern.charAt(j - 1);
- }
- if ((delimStop != DELIM_STOP) || (escape == '\\')) {
- // invalid DELIM_START/DELIM_STOP pair or espace character is
- // present
- return messagePattern;
- } else {
- StringBuffer sbuf = new StringBuffer(len + 20);
- sbuf.append(messagePattern.substring(0, j));
- sbuf.append(argument);
- sbuf.append(messagePattern.substring(j + 2));
- return sbuf.toString();
- }
+public final class MessageFormatter {
+ /**
+ * Private formatter since all methods and members are static.
+ */
+ private MessageFormatter() {
+ super();
}
- }
- /**
- * /**
- * Performs a two argument substitution for the 'messagePattern' passed as
- * parameter.
- * <p>
- * For example, <code>MessageFormatter.format("Hi {}. My name is {}.",
- * "there", "David");</code> will return the string "Hi there. My name is David.".
- * <p>
- * The '{}' pair is called a formatting element. It serves to designate the
- * location where the arguments need to be inserted within the message pattern.
- *
- * @param messagePattern The message pattern which will be parsed and formatted
- * @param arg1 The first argument to replace the first formatting element
- * @param arg2 The second argument to replace the second formatting element
- * @return The formatted message
- */
- public static String format(String messagePattern, Object arg1, Object arg2) {
- int i = 0;
- int len = messagePattern.length();
- int j = messagePattern.indexOf(DELIM_START);
-
- StringBuffer sbuf = new StringBuffer(messagePattern.length() + 50);
-
- for (int L = 0; L < 2; L++) {
- j = messagePattern.indexOf(DELIM_START, i);
-
- if (j == -1 || (j+1 == len)) {
- // no more variables
- if (i == 0) { // this is a simple string
- return messagePattern;
- } else { // add the tail string which contains no variables and return the result.
- sbuf.append(messagePattern.substring(i, messagePattern.length()));
- return sbuf.toString();
+ /**
+ * Start of replacement block.
+ */
+ private static final char DELIM_START = '{';
+ /**
+ * End of replacement block.
+ */
+ private static final char DELIM_STOP = '}';
+
+ /**
+ * Performs single argument substitution for the 'messagePattern' passed as
+ * parameter.
+ * <p/>
+ * For example, <code>MessageFormatter.format("Hi {}.", "there");</code>
+ * will return the string "Hi there.".
+ * <p/>
+ * The {} pair is called the formatting element. It serves to designate the
+ * location where the argument needs to be inserted within the pattern.
+ *
+ * @param messagePattern
+ * The message pattern which will be parsed and formatted
+ * @param argument
+ * The argument to be inserted instead of the formatting element
+ * @return The formatted message
+ */
+ public static String format(final String messagePattern,
+ final Object argument) {
+ int j = messagePattern.indexOf(DELIM_START);
+ int len = messagePattern.length();
+ char escape = 'x';
+
+ // if there are no { characters or { is the last character
+ // then we just return messagePattern
+ if (j == -1 || (j + 1 == len)) {
+ return messagePattern;
+ } else {
+ char delimStop = messagePattern.charAt(j + 1);
+ if (j > 0) {
+ escape = messagePattern.charAt(j - 1);
+ }
+ if ((delimStop != DELIM_STOP) || (escape == '\\')) {
+ // invalid DELIM_START/DELIM_STOP pair or espace character is
+ // present
+ return messagePattern;
+ } else {
+ StringBuffer sbuf = new StringBuffer(len + 20);
+ sbuf.append(messagePattern.substring(0, j));
+ sbuf.append(argument);
+ sbuf.append(messagePattern.substring(j + 2));
+ return sbuf.toString();
+ }
}
- } else {
- char delimStop = messagePattern.charAt(j + 1);
- if ((delimStop != DELIM_STOP)) {
- // invalid DELIM_START/DELIM_STOP pair
- sbuf.append(messagePattern.substring(i, messagePattern.length()));
- return sbuf.toString();
+ }
+
+ /**
+ * /**
+ * Performs a two argument substitution for the 'messagePattern' passed as
+ * parameter.
+ * <p/>
+ * For example, <code>MessageFormatter.format("Hi {}. My name is {}.",
+ * "there", "David");</code> will return the string
+ * "Hi there. My name is David.".
+ * <p/>
+ * The '{}' pair is called a formatting element. It serves to designate the
+ * location where the arguments need to be inserted within
+ * the message pattern.
+ *
+ * @param messagePattern
+ * The message pattern which will be parsed and formatted
+ * @param arg1
+ * The first argument to replace the first formatting element
+ * @param arg2
+ * The second argument to replace the second formatting element
+ * @return The formatted message
+ */
+ public static String format(final String messagePattern,
+ final Object arg1,
+ final Object arg2) {
+ int i = 0;
+ int len = messagePattern.length();
+
+ StringBuffer sbuf = new StringBuffer(messagePattern.length() + 50);
+
+ for (int l = 0; l < 2; l++) {
+ int j = messagePattern.indexOf(DELIM_START, i);
+
+ if (j == -1 || (j + 1 == len)) {
+ // no more variables
+ if (i == 0) { // this is a simple string
+ return messagePattern;
+ } else {
+ // add the tail string which contains no variables
+ // and return the result.
+ sbuf.append(messagePattern.substring(i,
+ messagePattern.length()));
+ return sbuf.toString();
+ }
+ } else {
+ char delimStop = messagePattern.charAt(j + 1);
+ if ((delimStop != DELIM_STOP)) {
+ // invalid DELIM_START/DELIM_STOP pair
+ sbuf.append(messagePattern.substring(i,
+ messagePattern.length()));
+ return sbuf.toString();
+ }
+ sbuf.append(messagePattern.substring(i, j));
+ if (l == 0) {
+ sbuf.append(arg1);
+ } else {
+ sbuf.append(arg2);
+ }
+ i = j + 2;
+ }
}
- sbuf.append(messagePattern.substring(i, j));
- sbuf.append((L == 0) ? arg1 : arg2);
- i = j + 2;
- }
+ // append the characters following the second {} pair.
+ sbuf.append(messagePattern.substring(i, messagePattern.length()));
+ return sbuf.toString();
}
- // append the characters following the second {} pair.
- sbuf.append(messagePattern.substring(i, messagePattern.length()));
- return sbuf.toString();
- }
}
Modified: logging/log4j/trunk/src/java/org/apache/log4j/spi/Component.java
URL: http://svn.apache.org/viewvc/logging/log4j/trunk/src/java/org/apache/log4j/spi/Component.java?view=diff&rev=527671&r1=527670&r2=527671
==============================================================================
--- logging/log4j/trunk/src/java/org/apache/log4j/spi/Component.java (original)
+++ logging/log4j/trunk/src/java/org/apache/log4j/spi/Component.java Wed Apr 11 14:04:39 2007
@@ -1,29 +1,38 @@
/*
- * Created on Jan 3, 2005
+ * 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
*
- * To change the template for this generated file go to
- * Window>Preferences>Java>Code Generation>Code and Comments
+ * 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.spi;
/**
* A common interface shared by log4j components.
- *
+ *
* @author Ceki Gulcu
* @since 1.3
*/
public interface Component {
-
- /**
- * Set owning logger repository for this component. This operation can
- * only be performed once. Once set, the owning repository cannot be changed.
- *
- * @param repository The repository where this appender is attached.
- * @throws IllegalStateException If you try to change the repository after it
- * has been set.
- **/
- public void setLoggerRepository(LoggerRepository repository);
-
+
+ /**
+ * Set owning logger repository for this component. This operation can
+ * only be performed once.
+ * Once set, a subsequent attempt will throw an IllegalStateException.
+ *
+ * @param repository The repository where this appender is attached.
+ */
+ void setLoggerRepository(LoggerRepository repository);
+
}
Modified: logging/log4j/trunk/src/java/org/apache/log4j/spi/ComponentBase.java
URL: http://svn.apache.org/viewvc/logging/log4j/trunk/src/java/org/apache/log4j/spi/ComponentBase.java?view=diff&rev=527671&r1=527670&r2=527671
==============================================================================
--- logging/log4j/trunk/src/java/org/apache/log4j/spi/ComponentBase.java (original)
+++ logging/log4j/trunk/src/java/org/apache/log4j/spi/ComponentBase.java Wed Apr 11 14:04:39 2007
@@ -1,97 +1,121 @@
/*
- * Created on Jan 3, 2005
+ * 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
*
- * To change the template for this generated file go to
- * Window>Preferences>Java>Code Generation>Code and Comments
+ * 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.spi;
import org.apache.log4j.ULogger;
-import org.apache.log4j.spi.NOPULogger;
-import org.apache.log4j.spi.SimpleULogger;
/**
* Most log4j components derive from this class.
- *
+ *
* @author Ceki Gulcu
* @since 1.3
*/
public class ComponentBase implements Component {
- private final static int ERROR_COUNT_LIMIT = 3;
-
- protected LoggerRepository repository;
- private ULogger logger;
- private int errorCount = 0;
-
-
- /**
- * Called by derived classes when they deem that the component has recovered
- * from an erroneous state.
- */
- protected void resetErrorCount() {
- errorCount = 0;
- }
- /**
- * Set the owning repository. The owning repository cannot be set more than
- * once.
- */
- public void setLoggerRepository(LoggerRepository repository) {
- if(this.repository == null) {
- this.repository = repository;
- } else if(this.repository != repository) {
- throw new IllegalStateException("Repository has been already set");
- }
- }
-
- /**
- * Return the {@link LoggerRepository} this component is attached to.
- *
- * @return Owning LoggerRepository
- */
- protected LoggerRepository getLoggerRepository() {
- return repository;
- }
-
- /**
- * Return an instance specific logger to be used by the component itself.
- * This logger is not intended to be accessed by the end-user, hence the
- * protected keyword.
- *
- * <p>In case the repository for this component is not set,
- * this implementations returns a {@link SimpleULogger} instance.
- *
- * @return A ULogger instance.
- */
- protected ULogger getLogger() {
- if(logger == null) {
- if(repository != null) {
- logger = repository.getLogger(this.getClass().getName());
- } else {
- logger = SimpleULogger.getLogger(this.getClass().getName());
- }
- } else if(repository != null && !(logger instanceof org.apache.log4j.Logger)){
- // if repository is set but logger is not an instance of Logger, we
- // could reset the logger, as in the line below. However, we chose not to
- // do so in order to make the bigger problem more apparent.
-
- // logger = repository.getLogger(this.getClass().getName());
- }
- return logger;
- }
-
- /**
- * Frequently called methods in log4j components can invoke this method in
- * order to avoid flooding the output when logging lasting error conditions.
- *
- * @return a regular logger, or a NOPLogger if called too frequently.
- */
- protected ULogger getNonFloodingLogger() {
- if(errorCount++ >= ERROR_COUNT_LIMIT) {
- return NOPULogger.NOP_LOGGER;
- } else {
- return getLogger();
+ /**
+ * Error count limit.
+ */
+ private static final int ERROR_COUNT_LIMIT = 3;
+
+ /**
+ * Logger repository.
+ */
+ protected LoggerRepository repository;
+ /**
+ * Logger.
+ */
+ private ULogger logger;
+ /**
+ * Error count.
+ */
+ private int errorCount = 0;
+
+ /**
+ * Construct a new instance.
+ */
+ protected ComponentBase() {
+ super();
+ }
+
+
+ /**
+ * Called by derived classes when they deem that the component has recovered
+ * from an erroneous state.
+ */
+ protected void resetErrorCount() {
+ errorCount = 0;
}
- }
+
+ /**
+ * Set the owning repository. The owning repository cannot be set more than
+ * once.
+ *
+ * @param repository repository
+ */
+ public void setLoggerRepository(final LoggerRepository repository) {
+ if (this.repository == null) {
+ this.repository = repository;
+ } else if (this.repository != repository) {
+ throw new IllegalStateException("Repository has been already set");
+ }
+ }
+
+ /**
+ * Return the {@link LoggerRepository} this component is attached to.
+ *
+ * @return Owning LoggerRepository
+ */
+ protected LoggerRepository getLoggerRepository() {
+ return repository;
+ }
+
+ /**
+ * Return an instance specific logger to be used by the component itself.
+ * This logger is not intended to be accessed by the end-user, hence the
+ * protected keyword.
+ * <p/>
+ * <p>In case the repository for this component is not set,
+ * this implementations returns a {@link SimpleULogger} instance.
+ *
+ * @return A ULogger instance.
+ */
+ protected ULogger getLogger() {
+ if (logger == null) {
+ if (repository != null) {
+ logger = repository.getLogger(this.getClass().getName());
+ } else {
+ logger = SimpleULogger.getLogger(this.getClass().getName());
+ }
+ }
+ return logger;
+ }
+
+ /**
+ * Frequently called methods in log4j components can invoke this method in
+ * order to avoid flooding the output when logging lasting error conditions.
+ *
+ * @return a regular logger, or a NOPLogger if called too frequently.
+ */
+ protected ULogger getNonFloodingLogger() {
+ if (errorCount++ >= ERROR_COUNT_LIMIT) {
+ return NOPULogger.NOP_LOGGER;
+ } else {
+ return getLogger();
+ }
+ }
}
Modified: logging/log4j/trunk/src/java/org/apache/log4j/spi/ErrorItem.java
URL: http://svn.apache.org/viewvc/logging/log4j/trunk/src/java/org/apache/log4j/spi/ErrorItem.java?view=diff&rev=527671&r1=527670&r2=527671
==============================================================================
--- logging/log4j/trunk/src/java/org/apache/log4j/spi/ErrorItem.java (original)
+++ logging/log4j/trunk/src/java/org/apache/log4j/spi/ErrorItem.java Wed Apr 11 14:04:39 2007
@@ -24,61 +24,119 @@
* logging. Such errors include those occurring during the initial phases
* of log4j configuration or errors emanating from core components such as
* Logger or Hierarchy.
- *
+ *
* @author Ceki Gulcu
*/
public class ErrorItem {
+ /**
+ * Message.
+ */
String message;
+ /**
+ * Column.
+ */
int colNumber = -1;
+ /**
+ * Line number.
+ */
int lineNumber = -1;
+ /**
+ * Exception.
+ */
Throwable exception;
- public ErrorItem(String message, Exception e) {
+ /**
+ * Create new instance.
+ * @param message message
+ * @param e exception
+ */
+ public ErrorItem(final String message, final Exception e) {
+ super();
this.message = message;
exception = e;
}
- public ErrorItem(String message) {
+ /**
+ * Creaet new instance.
+ * @param message message.
+ */
+ public ErrorItem(final String message) {
this(message, null);
}
+ /**
+ * Get column number.
+ * @return column number.
+ */
public int getColNumber() {
return colNumber;
}
+ /**
+ * Set column number.
+ * @param colNumber new column number.
+ */
public void setColNumber(int colNumber) {
this.colNumber = colNumber;
}
+ /**
+ * Get exception.
+ * @return exception.
+ */
public Throwable getException() {
return exception;
}
- public void setException(Throwable exception) {
+ /**
+ * Set exception.
+ * @param exception exception
+ */
+ public void setException(final Throwable exception) {
this.exception = exception;
}
+ /**
+ * Get line number.
+ * @return line number.
+ */
public int getLineNumber() {
return lineNumber;
}
- public void setLineNumber(int lineNumber) {
+ /**
+ * Set line number.
+ * @param lineNumber line number.
+ */
+ public void setLineNumber(final int lineNumber) {
this.lineNumber = lineNumber;
}
+ /**
+ * Get message.
+ * @return message.
+ */
public String getMessage() {
return message;
}
- public void setMessage(String message) {
+ /**
+ * Set message.
+ * @param message message.
+ */
+ public void setMessage(final String message) {
this.message = message;
}
+ /**
+ * String representation of ErrorItem.
+ * @return string.
+ */
public String toString() {
String str =
"Reported error: \"" + message + "\"";
-
- if(lineNumber != -1) {
+
+ if (lineNumber != -1) {
str += " at line " + lineNumber + " column " + colNumber;
}
if (exception != null) {
@@ -86,7 +144,7 @@
}
return str;
}
-
+
/**
* Dump the details of this ErrorItem to System.out.
*/
@@ -96,19 +154,19 @@
/**
* Dump the details of this ErrorItem on the specified {@link PrintStream}.
- * @param ps
+ * @param ps print stream.
*/
- public void dump(PrintStream ps) {
+ public void dump(final PrintStream ps) {
String str =
"Reported error: \"" + message + "\"";
-
- if(lineNumber != -1) {
+
+ if (lineNumber != -1) {
str += " at line " + lineNumber + " column " + colNumber;
}
ps.println(str);
-
- if(exception != null) {
+
+ if (exception != null) {
exception.printStackTrace(ps);
- }
+ }
}
}
Modified: logging/log4j/trunk/src/java/org/apache/log4j/spi/LoggerEventListener.java
URL: http://svn.apache.org/viewvc/logging/log4j/trunk/src/java/org/apache/log4j/spi/LoggerEventListener.java?view=diff&rev=527671&r1=527670&r2=527671
==============================================================================
--- logging/log4j/trunk/src/java/org/apache/log4j/spi/LoggerEventListener.java (original)
+++ logging/log4j/trunk/src/java/org/apache/log4j/spi/LoggerEventListener.java Wed Apr 11 14:04:39 2007
@@ -5,9 +5,9 @@
* 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.
@@ -43,18 +43,18 @@
@param logger The logger to which the appender was added.
@param appender The appender added to the logger. */
- public void appenderAddedEvent(Logger logger, Appender appender);
+ void appenderAddedEvent(Logger logger, Appender appender);
/**
Called when an appender is removed from the logger.
@param logger The logger from which the appender was removed.
@param appender The appender removed from the logger. */
- public void appenderRemovedEvent(Logger logger, Appender appender);
+ void appenderRemovedEvent(Logger logger, Appender appender);
/**
Called when level changed on the logger.
@param logger The logger that changed levels. */
- public void levelChangedEvent(Logger logger);
+ void levelChangedEvent(Logger logger);
}
Modified: logging/log4j/trunk/src/java/org/apache/log4j/spi/LoggerRepositoryEventListener.java
URL: http://svn.apache.org/viewvc/logging/log4j/trunk/src/java/org/apache/log4j/spi/LoggerRepositoryEventListener.java?view=diff&rev=527671&r1=527670&r2=527671
==============================================================================
--- logging/log4j/trunk/src/java/org/apache/log4j/spi/LoggerRepositoryEventListener.java (original)
+++ logging/log4j/trunk/src/java/org/apache/log4j/spi/LoggerRepositoryEventListener.java Wed Apr 11 14:04:39 2007
@@ -5,9 +5,9 @@
* 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.
@@ -33,16 +33,22 @@
*/
public interface LoggerRepositoryEventListener {
/**
- Called when the repository configuration is reset. */
- public void configurationResetEvent(LoggerRepository repository);
+ Called when the repository configuration is reset.
+ @param repository repository
+ */
+ void configurationResetEvent(LoggerRepository repository);
/**
- Called when the repository configuration is changed. */
- public void configurationChangedEvent(LoggerRepository repository);
+ Called when the repository configuration is changed.
+ @param repository repository
+ */
+ void configurationChangedEvent(LoggerRepository repository);
/**
Called when the repository is shutdown. When this method is
invoked, the repository is still valid (ie it has not been
- shutdown, but will be after this method returns). */
- public void shutdownEvent(LoggerRepository repository);
+ shutdown, but will be after this method returns).
+ @param repository repository.
+ */
+ void shutdownEvent(LoggerRepository repository);
}
Modified: logging/log4j/trunk/src/java/org/apache/log4j/spi/LoggerRepositoryEx.java
URL: http://svn.apache.org/viewvc/logging/log4j/trunk/src/java/org/apache/log4j/spi/LoggerRepositoryEx.java?view=diff&rev=527671&r1=527670&r2=527671
==============================================================================
--- logging/log4j/trunk/src/java/org/apache/log4j/spi/LoggerRepositoryEx.java (original)
+++ logging/log4j/trunk/src/java/org/apache/log4j/spi/LoggerRepositoryEx.java Wed Apr 11 14:04:39 2007
@@ -160,14 +160,14 @@
void setProperty(String key, String value);
/**
- * Errors which cannot be logged, go to the error list
+ * Errors which cannot be logged, go to the error list.
*
* @return List
*/
List getErrorList();
/**
- * Errors which cannot be logged, go to the error list
+ * Errors which cannot be logged, go to the error list.
*
* @param errorItem an ErrorItem to add to the error list
*/
@@ -193,16 +193,15 @@
/**
* Sets the logger factory used by {@link LoggerRepository#getLogger(String)}.
- *
* @param loggerFactory factory to use, may not be null
- * @throws NullPointerException factory is null
* @since 1.3
*/
void setLoggerFactory(LoggerFactory loggerFactory);
/**
- * Returns the logger factory used by {@link LoggerRepository#getLogger(String)}.
- *
+ * Returns the logger factory used by
+ * {@link LoggerRepository#getLogger(String)}.
+ *
* @return non-null factory
* @since 1.3
*/
Modified: logging/log4j/trunk/src/java/org/apache/log4j/spi/NOPULogger.java
URL: http://svn.apache.org/viewvc/logging/log4j/trunk/src/java/org/apache/log4j/spi/NOPULogger.java?view=diff&rev=527671&r1=527670&r2=527671
==============================================================================
--- logging/log4j/trunk/src/java/org/apache/log4j/spi/NOPULogger.java (original)
+++ logging/log4j/trunk/src/java/org/apache/log4j/spi/NOPULogger.java Wed Apr 11 14:04:39 2007
@@ -21,167 +21,180 @@
/**
* A no operation (NOP) implementation of {@link ULogger}.
- *
+ *
* @author Ceki Gülcü
*/
-public class NOPULogger implements ULogger {
+public final class NOPULogger implements ULogger {
- /**
- * The unique instance of NOPLogger.
- */
- public final static NOPULogger NOP_LOGGER = new NOPULogger();
-
- /**
- * There is no point in people creating multiple instances of NullLogger.
- * Hence, the private access modifier.
- */
- private NOPULogger() {
- }
-
- public static NOPULogger getLogger(final String name) {
- return NOP_LOGGER;
- }
-
- /* Always returns false.
- *
- * @see org.apache.ugli.Logger#isDebugEnabled()
- */
- public boolean isDebugEnabled() {
- return false;
- }
-
- /* A NOP implementation.
- * @see org.apache.ugli.Logger#debug(java.lang.Object)
- */
- public void debug(Object msg) {
- // NOP
- }
-
- /* A NOP implementation.
- * @see org.apache.ugli.Logger#debug(java.lang.Object, java.lang.Object)
- */
- public void debug(Object parameterizedMsg, Object param1) {
- // NOP
- }
-
- /* A NOP implementation.
- * @see org.apache.ugli.Logger#debug(java.lang.Object, java.lang.Object, java.lang.Object)
- */
- public void debug(String parameterizedMsg, Object param1, Object param2) {
- // NOP
- }
-
- /* A NOP implementation.
- * @see org.apache.ugli.Logger#debug(java.lang.Object, java.lang.Throwable)
- */
- public void debug(Object msg, Throwable t) {
- // NOP
- }
-
- /* Always returns false.
- * @see org.apache.ugli.Logger#isInfoEnabled()
- */
- public boolean isInfoEnabled() {
- // NOP
- return false;
- }
-
- /* A NOP implementation.
- * @see org.apache.ugli.Logger#info(java.lang.Object)
- */
- public void info(Object msg) {
- // NOP
- }
-
- /* A NOP implementation.
- * @see org.apache.ugli.Logger#info(java.lang.Object, java.lang.Object)
- */
- public void info(Object parameterizedMsg, Object param1) {
- // NOP
- }
-
- /* A NOP implementation.
- * @see org.apache.ugli.Logger#info(java.lang.Object, java.lang.Object, java.lang.Object)
- */
- public void info(String parameterizedMsg, Object param1, Object param2) {
- // NOP
- }
-
- /* A NOP implementation.
- * @see org.apache.ugli.Logger#info(java.lang.Object, java.lang.Throwable)
- */
- public void info(Object msg, Throwable t) {
- // NOP
- }
-
- /* Always returns false.
- * @see org.apache.ugli.Logger#isWarnEnabled()
- */
- public boolean isWarnEnabled() {
- return false;
- }
-
- /* A NOP implementation.
- * @see org.apache.ugli.Logger#warn(java.lang.Object)
- */
- public void warn(Object msg) {
- // NOP
- }
-
- /* A NOP implementation.
- * @see org.apache.ugli.Logger#warn(java.lang.Object, java.lang.Object)
- */
- public void warn(Object parameterizedMsg, Object param1) {
- // NOP
- }
-
- /* A NOP implementation.
- * @see org.apache.ugli.Logger#warn(java.lang.Object, java.lang.Object, java.lang.Object)
- */
- public void warn(String parameterizedMsg, Object param1, Object param2) {
- // NOP
- }
-
- /* A NOP implementation.
- * @see org.apache.ugli.Logger#warn(java.lang.Object, java.lang.Throwable)
- */
- public void warn(Object msg, Throwable t) {
- // NOP
- }
-
- /* Always returns false.
- * @see org.apache.ugli.Logger#isErrorEnabled()
- */
- public boolean isErrorEnabled() {
- return false;
- }
-
- /* A NOP implementation.
- * @see org.apache.ugli.Logger#error(java.lang.Object)
- */
- public void error(Object msg) {
- // NOP
- }
-
- /* A NOP implementation.
- * @see org.apache.ugli.Logger#error(java.lang.Object, java.lang.Object)
- */
- public void error(Object parameterizedMsg, Object param1) {
- // NOP
- }
-
- /* A NOP implementation.
- * @see org.apache.ugli.Logger#error(java.lang.Object, java.lang.Object, java.lang.Object)
- */
- public void error(String parameterizedMsg, Object param1, Object param2) {
- // NOP
- }
-
- /* A NOP implementation.
- * @see org.apache.ugli.Logger#error(java.lang.Object, java.lang.Throwable)
- */
- public void error(Object msg, Throwable t) {
- // NOP
- }
+ /**
+ * The unique instance of NOPLogger.
+ */
+ public static final NOPULogger NOP_LOGGER = new NOPULogger();
+
+ /**
+ * There is no point in people creating multiple instances of NullLogger.
+ * Hence, the private access modifier.
+ */
+ private NOPULogger() {
+ super();
+ }
+
+ /**
+ * Get instance.
+ * @param name logger name.
+ * @return logger.
+ */
+ public static NOPULogger getLogger(final String name) {
+ return NOP_LOGGER;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public boolean isDebugEnabled() {
+ return false;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void debug(final Object msg) {
+ // NOP
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void debug(final Object parameterizedMsg, final Object param1) {
+ // NOP
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void debug(final String parameterizedMsg,
+ final Object param1,
+ final Object param2) {
+ // NOP
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void debug(final Object msg, final Throwable t) {
+ // NOP
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public boolean isInfoEnabled() {
+ // NOP
+ return false;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void info(final Object msg) {
+ // NOP
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void info(final Object parameterizedMsg, final Object param1) {
+ // NOP
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void info(final String parameterizedMsg,
+ final Object param1, final Object param2) {
+ // NOP
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void info(final Object msg, final Throwable t) {
+ // NOP
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public boolean isWarnEnabled() {
+ return false;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void warn(final Object msg) {
+ // NOP
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void warn(final Object parameterizedMsg,
+ final Object param1) {
+ // NOP
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void warn(final String parameterizedMsg,
+ final Object param1,
+ final Object param2) {
+ // NOP
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void warn(final Object msg, final Throwable t) {
+ // NOP
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public boolean isErrorEnabled() {
+ return false;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void error(final Object msg) {
+ // NOP
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void error(final Object parameterizedMsg, final Object param1) {
+ // NOP
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void error(final String parameterizedMsg,
+ final Object param1,
+ final Object param2) {
+ // NOP
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void error(final Object msg, final Throwable t) {
+ // NOP
+ }
}
Modified: logging/log4j/trunk/src/java/org/apache/log4j/spi/SimpleULogger.java
URL: http://svn.apache.org/viewvc/logging/log4j/trunk/src/java/org/apache/log4j/spi/SimpleULogger.java?view=diff&rev=527671&r1=527670&r2=527671
==============================================================================
--- logging/log4j/trunk/src/java/org/apache/log4j/spi/SimpleULogger.java (original)
+++ logging/log4j/trunk/src/java/org/apache/log4j/spi/SimpleULogger.java Wed Apr 11 14:04:39 2007
@@ -22,45 +22,64 @@
/**
* A simple implementation that logs messages of level INFO or higher on
- * the console (<code>System.out<code>).
+ * the console (<code>System.out</code>).
* <p>
- * The output includes the relative time in milliseconds, thread name, the level,
- * logger name, and the message followed by the line separator for the host.
+ * The output includes the relative time in milliseconds, thread name, level,
+ * logger name, and the message followed by the line separator for the host.
* In log4j terms it amounts to the "%r [%t] %level %logger - %m%n" pattern.
* <pre>
-176 [main] INFO examples.Sort - Populating an array of 2 elements in reverse order.
+176 [main] INFO examples.Sort - Populating an array of 2 elements in reverse.
225 [main] INFO examples.SortAlgo - Entered the sort method.
304 [main] INFO SortAlgo.DUMP - Dump of interger array:
317 [main] INFO SortAlgo.DUMP - Element [0] = 0
331 [main] INFO SortAlgo.DUMP - Element [1] = 1
-343 [main] INFO examples.Sort - The next log statement should be an error message.
+343 [main] INFO examples.Sort - The next log statement should be an error msg.
346 [main] ERROR SortAlgo.DUMP - Tried to dump an uninitialized array.
at org.log4j.examples.SortAlgo.dump(SortAlgo.java:58)
at org.log4j.examples.Sort.main(Sort.java:64)
467 [main] INFO examples.Sort - Exiting main method.
</pre>
- *
+ *
* @author Ceki Gülcü
*/
-public class SimpleULogger implements ULogger {
+public final class SimpleULogger implements ULogger {
+ /**
+ * Logger name.
+ */
private final String loggerName;
-
+
+
/**
* Mark the time when this class gets loaded into memory.
*/
private static long startTime = System.currentTimeMillis();
-
- public static final String LINE_SEPARATOR = System.getProperty("line.separator");
-
- static private String INFO_STR = "INFO";
- static private String WARN_STR = "WARN";
- static private String ERROR_STR = "ERROR";
-
+
+ /**
+ * Line separator.
+ */
+ public static final String LINE_SEPARATOR
+ = System.getProperty("line.separator");
+
+ /**
+ * INFO string literal.
+ */
+ private static final String INFO_STR = "INFO";
+ /**
+ * WARN string literal.
+ */
+ private static final String WARN_STR = "WARN";
+ /**
+ * ERROR string literal.
+ */
+ private static final String ERROR_STR = "ERROR";
+
/**
* Constructor is private to force construction through getLogger.
+ * @param name logger name
*/
private SimpleULogger(final String name) {
+ super();
this.loggerName = name;
}
@@ -75,81 +94,85 @@
}
/**
- * Always returns false.
+ * {@inheritDoc}
*/
public boolean isDebugEnabled() {
return false;
}
- /**
- * A NOP implementation.
- */
- public void debug(Object msg) {
+ /**
+ * {@inheritDoc}
+ */
+ public void debug(final Object msg) {
// NOP
}
- /**
- * A NOP implementation.
- */
- public void debug(Object parameterizedMsg, Object param1) {
+ /**
+ * {@inheritDoc}
+ */
+ public void debug(final Object parameterizedMsg, final Object param1) {
// NOP
}
- /**
- * A NOP implementation.
- */
- public void debug(String parameterizedMsg, Object param1, Object param2) {
+ /**
+ * {@inheritDoc}
+ */
+ public void debug(final String parameterizedMsg,
+ final Object param1,
+ final Object param2) {
// NOP
}
- /**
- * A NOP implementation.
- */
- public void debug(Object msg, Throwable t) {
+ /**
+ * {@inheritDoc}
+ */
+ public void debug(final Object msg, final Throwable t) {
// NOP
}
/**
* This is our internal implementation for logging regular (non-parameterized)
* log messages.
- *
- * @param level
- * @param message
- * @param t
- */
- private void log(final String level, final String message, final Throwable t) {
+ *
+ * @param level level
+ * @param message message
+ * @param t throwable
+ */
+ private void log(final String level,
+ final String message,
+ final Throwable t) {
StringBuffer buf = new StringBuffer();
-
+
long millis = System.currentTimeMillis();
- buf.append(millis-startTime);
-
+ buf.append(millis - startTime);
+
buf.append(" [");
buf.append(Thread.currentThread().getName());
buf.append("] ");
-
+
buf.append(level);
buf.append(" ");
-
+
buf.append(loggerName);
buf.append(" - ");
buf.append(message);
buf.append(LINE_SEPARATOR);
-
+
System.out.print(buf.toString());
- if(t != null) {
+ if (t != null) {
t.printStackTrace(System.out);
}
System.out.flush();
}
/**
* For parameterized messages, first substitute parameters and then log.
- *
- * @param level
- * @param parameterizedMsg
- * @param param1
- * @param param2
+ *
+ * @param level level
+ * @param parameterizedMsg message pattern
+ * @param param1 param1
+ * @param param2 param2
*/
private void parameterizedLog(final String level,
final Object parameterizedMsg,
@@ -165,120 +188,116 @@
log(level, parameterizedMsg.toString(), null);
}
}
-
- /**
- * Always returns true.
- */
+
+ /**
+ * {@inheritDoc}
+ */
public boolean isInfoEnabled() {
return true;
}
- /**
- * A simple implementation which always logs messages of level INFO according
- * to the format outlined above.
- */
+ /**
+ * {@inheritDoc}
+ */
public void info(final Object msg) {
log(INFO_STR, msg.toString(), null);
}
-
- /**
- * Perform single parameter substitution before logging the message of level
- * INFO according to the format outlined above.
- */
+
+ /**
+ * {@inheritDoc}
+ */
public void info(final Object parameterizedMsg, final Object param1) {
parameterizedLog(INFO_STR, parameterizedMsg, param1, null);
}
- /**
- * Perform double parameter substitution before logging the message of level
- * INFO according to the format outlined above.
- */
-
- public void info(final String parameterizedMsg, final Object param1, final Object param2) {
+ /**
+ * {@inheritDoc}
+ */
+ public void info(final String parameterizedMsg,
+ final Object param1,
+ final Object param2) {
parameterizedLog(INFO_STR, parameterizedMsg, param1, param2);
}
- /**
- * Log a message of level INFO, including an exception.
- */
+ /**
+ * {@inheritDoc}
+ */
public void info(final Object msg, final Throwable t) {
log(INFO_STR, msg.toString(), t);
}
- /**
- * Always returns true.
- */
+ /**
+ * {@inheritDoc}
+ */
public boolean isWarnEnabled() {
return true;
}
- /**
- * A simple implementation which always logs messages of level WARN according
- * to the format outlined above.
- */
+ /**
+ * {@inheritDoc}
+ */
public void warn(final Object msg) {
log(WARN_STR, msg.toString(), null);
}
- /**
- * Perform single parameter substitution before logging the message of level
- * WARN according to the format outlined above.
- */
+ /**
+ * {@inheritDoc}
+ */
public void warn(final Object parameterizedMsg, final Object param1) {
parameterizedLog(WARN_STR, parameterizedMsg, param1, null);
}
- /**
- * Perform double parameter substitution before logging the message of level
- * WARN according to the format outlined above.
- */
- public void warn(final String parameterizedMsg, final Object param1, final Object param2) {
+ /**
+ * {@inheritDoc}
+ */
+ public void warn(final String parameterizedMsg,
+ final Object param1,
+ final Object param2) {
parameterizedLog(WARN_STR, parameterizedMsg, param1, param2);
}
- /**
- * Log a message of level WARN, including an exception.
- */
+ /**
+ * {@inheritDoc}
+ */
public void warn(final Object msg, final Throwable t) {
log(WARN_STR, msg.toString(), t);
}
- /**
- * Always returns true.
- */
+ /**
+ * {@inheritDoc}
+ */
public boolean isErrorEnabled() {
return true;
}
- /**
- * A simple implementation which always logs messages of level ERROR acoording
- * to the format outlined above.
- */
+ /**
+ * {@inheritDoc}
+ */
public void error(final Object msg) {
log(ERROR_STR, msg.toString(), null);
}
- /**
- * Perform single parameter substitution before logging the message of level
- * ERROR according to the format outlined above.
- */
+ /**
+ * {@inheritDoc}
+ */
public void error(final Object parameterizedMsg, final Object param1) {
parameterizedLog(ERROR_STR, parameterizedMsg, param1, null);
}
- /**
- * Perform double parameter substitution before logging the message of level
- * ERROR according to the format outlined above.
- */
- public void error(final String parameterizedMsg, final Object param1, final Object param2) {
+ /**
+ * {@inheritDoc}
+ */
+ public void error(final String parameterizedMsg,
+ final Object param1,
+ final Object param2) {
parameterizedLog(ERROR_STR, parameterizedMsg, param1, param2);
}
- /**
- * Log a message of level ERROR, including an exception.
- */
+ /**
+ * {@inheritDoc}
+ */
public void error(final Object msg, final Throwable t) {
log(ERROR_STR, msg.toString(), t);
}
Modified: logging/log4j/trunk/src/java/org/apache/log4j/spi/Thresholdable.java
URL: http://svn.apache.org/viewvc/logging/log4j/trunk/src/java/org/apache/log4j/spi/Thresholdable.java?view=diff&rev=527671&r1=527670&r2=527671
==============================================================================
--- logging/log4j/trunk/src/java/org/apache/log4j/spi/Thresholdable.java (original)
+++ logging/log4j/trunk/src/java/org/apache/log4j/spi/Thresholdable.java Wed Apr 11 14:04:39 2007
@@ -5,9 +5,9 @@
* 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.
@@ -20,37 +20,40 @@
import org.apache.log4j.Level;
/**
- An interface that defines the required methods for supporting the
- setting and getting of a level threshold. Components should implement
- this interface if logging events they process should meet a certain
- threshold before being processed further. Examples of this are
- Appenders and Receivers which will not process logging events unless
- the event level is at or greater than a set threshold level.
-
- @author Paul Smith <ps...@apache.org>
- @author Mark Womack
- @since 1.3
+ * An interface that defines the required methods for supporting the
+ * setting and getting of a level threshold. Components should implement
+ * this interface if logging events they process should meet a certain
+ * threshold before being processed further. Examples of this are
+ * Appenders and Receivers which will not process logging events unless
+ * the event level is at or greater than a set threshold level.
+ *
+ * @author Paul Smith (psmith@apache.org)
+ * @author Mark Womack
+ * @since 1.3
*/
public interface Thresholdable {
- /**
- Sets the component theshold to the given level.
-
- @param level The threshold level events must equal or be greater
- than before further processing can be done. */
- public void setThreshold(Level level);
-
- /**
- Gets the current threshold setting of the component.
-
- @return Level The current threshold level of the component. */
- public Level getThreshold();
-
- /**
- Returns true if the given level is equals or greater than the current
- threshold value of the component.
-
- @param level The level to test against the component threshold.
- @return boolean True if level is equal or greater than the
- component threshold. */
- public boolean isAsSevereAsThreshold(Level level);
+ /**
+ * Sets the component theshold to the given level.
+ *
+ * @param level The threshold level events must equal or be greater
+ * than before further processing can be done.
+ */
+ void setThreshold(Level level);
+
+ /**
+ * Gets the current threshold setting of the component.
+ *
+ * @return Level The current threshold level of the component.
+ */
+ Level getThreshold();
+
+ /**
+ * Returns true if the given level is equals or greater than the current
+ * threshold value of the component.
+ *
+ * @param level The level to test against the component threshold.
+ * @return boolean True if level is equal or greater than the
+ * component threshold.
+ */
+ boolean isAsSevereAsThreshold(Level level);
}
---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-dev-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-dev-help@logging.apache.org