ceki 2004/11/22 08:43:39
Modified: src/java/org/apache/log4j FileAppender.java Logger.java
Category.java
Log:
- Ensuring JDK 1.3 compile-time compatibility.
- Moved trace() methods to Logger as these are new 1.3.
Revision Changes Path
1.44 +1 -1 logging-log4j/src/java/org/apache/log4j/FileAppender.java
Index: FileAppender.java
===================================================================
RCS file:
/home/cvs/logging-log4j/src/java/org/apache/log4j/FileAppender.java,v
retrieving revision 1.43
retrieving revision 1.44
diff -u -r1.43 -r1.44
--- FileAppender.java 17 Nov 2004 21:25:23 -0000 1.43
+++ FileAppender.java 22 Nov 2004 16:43:39 -0000 1.44
@@ -243,7 +243,7 @@
public synchronized void setFile(
String filename, boolean append, boolean bufferedIO, int bufferSize)
throws IOException {
- getLogger().debug("setFile called: {}, {}", fileName,
Boolean.toString(append));
+ getLogger().debug("setFile called: {}, {}", fileName,
append?"true":"false");
// It does not make sense to have immediate flush and bufferedIO.
if (bufferedIO) {
1.26 +38 -157 logging-log4j/src/java/org/apache/log4j/Logger.java
Index: Logger.java
===================================================================
RCS file: /home/cvs/logging-log4j/src/java/org/apache/log4j/Logger.java,v
retrieving revision 1.25
retrieving revision 1.26
diff -u -r1.25 -r1.26
--- Logger.java 2 Nov 2004 19:37:19 -0000 1.25
+++ Logger.java 22 Nov 2004 16:43:39 -0000 1.26
@@ -108,6 +108,44 @@
public static Logger getLogger(String name, LoggerFactory factory) {
return LogManager.getLogger(name, factory);
}
+
+ /**
+ * Log a message object with the [EMAIL PROTECTED] Level#TRACE TRACE}
level.
+ *
+ * @param message the message object to log.
+ * @see #debug(Object) for an explanation of the logic applied.
+ * @since 1.3
+ */
+ public void trace(Object message) {
+ if (repository.isDisabled(Level.TRACE_INT)) {
+ return;
+ }
+
+ if (Level.TRACE.isGreaterOrEqual(this.getEffectiveLevel())) {
+ forcedLog(FQCN, Level.TRACE, message, null);
+ }
+ }
+
+ /**
+ * Log a message object with the <code>TRACE</code> level including the
+ * stack trace of the [EMAIL PROTECTED] Throwable}<code>t</code> passed as
parameter.
+ *
+ * <p>
+ * See [EMAIL PROTECTED] #debug(Object)} form for more detailed
information.
+ * </p>
+ *
+ * @param message the message object to log.
+ * @param t the exception to log, including its stack trace.
+ */
+ public void trace(Object message, Throwable t) {
+ if (repository.isDisabled(Level.TRACE_INT)) {
+ return;
+ }
+
+ if (Level.TRACE.isGreaterOrEqual(this.getEffectiveLevel())) {
+ forcedLog(FQCN, Level.TRACE, message, t);
+ }
+ }
/**
* Log a message with the <code>TRACE</code> level with message formatting
@@ -165,38 +203,6 @@
/**
* Log a message with the <code>DEBUG</code> level with message formatting
- * done according to the value of <code>messagePattern</code> and
- * <code>arg</code> parameters.
- * <p>
- * This form avoids superflous parameter construction. Whenever possible,
- * you should use this form instead of constructing the message parameter
- * using string concatenation.
- *
- * @param messagePattern The message pattern which will be parsed and
formatted
- * @param arg The argument to replace the formatting element, i,e,
- * the '{}' pair within <code>messagePattern</code>.
- * @since 1.3
- */
- public void debug(Object messagePattern, Object arg) {
- if (repository.isDisabled(Level.DEBUG_INT)) {
- return;
- }
-
- if (Level.DEBUG.isGreaterOrEqual(this.getEffectiveLevel())) {
- if (messagePattern instanceof String){
- String msgStr = (String) messagePattern;
- msgStr = MessageFormatter.format(msgStr, arg);
- forcedLog(FQCN, Level.DEBUG, msgStr, null);
- } else {
- // To be failsafe, we handle the case where 'messagePattern' is not
- // a String. Unless the user makes a mistake, this should never
happen.
- forcedLog(FQCN, Level.DEBUG, messagePattern, null);
- }
- }
- }
-
- /**
- * Log a message with the <code>DEBUG</code> level with message formatting
* done according to the messagePattern and the arguments arg1 and arg2.
* <p>
* This form avoids superflous parameter construction. Whenever possible,
@@ -220,38 +226,6 @@
/**
* Log a message with the <code>INFO</code> level with message formatting
- * done according to the value of <code>messagePattern</code> and
- * <code>arg</code> parameters.
- * <p>
- * This form avoids superflous parameter construction. Whenever possible,
- * you should use this form instead of constructing the message parameter
- * using string concatenation.
- *
- * @param messagePattern The message pattern which will be parsed and
formatted
- * @param arg The argument to replace the formatting element, i,e,
- * the '{}' pair within <code>messagePattern</code>.
- * @since 1.3
- */
- public void info(Object messagePattern, Object arg) {
- if (repository.isDisabled(Level.INFO_INT)) {
- return;
- }
-
- if (Level.INFO.isGreaterOrEqual(this.getEffectiveLevel())) {
- if (messagePattern instanceof String){
- String msgStr = (String) messagePattern;
- msgStr = MessageFormatter.format(msgStr, arg);
- forcedLog(FQCN, Level.INFO, msgStr, null);
- } else {
- // To be failsafe, we handle the case where 'messagePattern' is not
- // a String. Unless the user makes a mistake, this should never
happen.
- forcedLog(FQCN, Level.INFO, messagePattern, null);
- }
- }
- }
-
- /**
- * Log a message with the <code>INFO</code> level with message formatting
* done according to the messagePattern and the arguments arg1 and arg2.
* <p>
* This form avoids superflous parameter construction. Whenever possible,
@@ -273,37 +247,6 @@
}
}
- /**
- * Log a message with the <code>WARN</code> level with message formatting
- * done according to the value of <code>messagePattern</code> and
- * <code>arg</code> parameters.
- * <p>
- * This form avoids superflous parameter construction. Whenever possible,
- * you should use this form instead of constructing the message parameter
- * using string concatenation.
- *
- * @param messagePattern The message pattern which will be parsed and
formatted
- * @param arg The argument to replace the formatting element, i,e,
- * the '{}' pair within <code>messagePattern</code>.
- * @since 1.3
- */
- public void warn(Object messagePattern, Object arg) {
- if (repository.isDisabled(Level.WARN_INT)) {
- return;
- }
-
- if (Level.WARN.isGreaterOrEqual(this.getEffectiveLevel())) {
- if (messagePattern instanceof String){
- String msgStr = (String) messagePattern;
- msgStr = MessageFormatter.format(msgStr, arg);
- forcedLog(FQCN, Level.WARN, msgStr, null);
- } else {
- // To be failsafe, we handle the case where 'messagePattern' is not
- // a String. Unless the user makes a mistake, this should never
happen.
- forcedLog(FQCN, Level.WARN, messagePattern, null);
- }
- }
- }
/**
* Log a message with the <code>WARN</code> level with message formatting
@@ -328,37 +271,7 @@
}
}
- /**
- * Log a message with the <code>ERROR</code> level with message formatting
- * done according to the value of <code>messagePattern</code> and
- * <code>arg</code> parameters.
- * <p>
- * This form avoids superflous parameter construction. Whenever possible,
- * you should use this form instead of constructing the message parameter
- * using string concatenation.
- *
- * @param messagePattern The message pattern which will be parsed and
formatted
- * @param arg The argument to replace the formatting element, i,e,
- * the '{}' pair within <code>messagePattern</code>.
- * @since 1.3
- */
- public void error(Object messagePattern, Object arg) {
- if (repository.isDisabled(Level.ERROR_INT)) {
- return;
- }
- if (Level.ERROR.isGreaterOrEqual(this.getEffectiveLevel())) {
- if (messagePattern instanceof String){
- String msgStr = (String) messagePattern;
- msgStr = MessageFormatter.format(msgStr, arg);
- forcedLog(FQCN, Level.ERROR, msgStr, null);
- } else {
- // To be failsafe, we handle the case where 'messagePattern' is not
- // a String. Unless the user makes a mistake, this should never
happen.
- forcedLog(FQCN, Level.ERROR, messagePattern, null);
- }
- }
- }
/**
* Log a message with the <code>ERROR</code> level with message formatting
@@ -380,38 +293,6 @@
if (Level.ERROR.isGreaterOrEqual(this.getEffectiveLevel())) {
messagePattern = MessageFormatter.format(messagePattern, arg1, arg2);
forcedLog(FQCN, Level.ERROR, messagePattern, null);
- }
- }
-
- /**
- * Log a message with the <code>FATAL</code> level with message formatting
- * done according to the value of <code>messagePattern</code> and
- * <code>arg</code> parameters.
- * <p>
- * This form avoids superflous parameter construction. Whenever possible,
- * you should use this form instead of constructing the message parameter
- * using string concatenation.
- *
- * @param messagePattern The message pattern which will be parsed and
formatted
- * @param arg The argument to replace the formatting element, i,e,
- * the '{}' pair within <code>messagePattern</code>.
- * @since 1.3
- */
- public void fatal(Object messagePattern, Object arg) {
- if (repository.isDisabled(Level.FATAL_INT)) {
- return;
- }
-
- if (Level.FATAL.isGreaterOrEqual(this.getEffectiveLevel())) {
- if (messagePattern instanceof String){
- String msgStr = (String) messagePattern;
- msgStr = MessageFormatter.format(msgStr, arg);
- forcedLog(FQCN, Level.FATAL, msgStr, null);
- } else {
- // To be failsafe, we handle the case where 'messagePattern' is not
- // a String. Unless the user makes a mistake, this should never
happen.
- forcedLog(FQCN, Level.FATAL, messagePattern, null);
- }
}
}
1.93 +162 -39 logging-log4j/src/java/org/apache/log4j/Category.java
Index: Category.java
===================================================================
RCS file: /home/cvs/logging-log4j/src/java/org/apache/log4j/Category.java,v
retrieving revision 1.92
retrieving revision 1.93
diff -u -r1.92 -r1.93
--- Category.java 2 Nov 2004 14:49:30 -0000 1.92
+++ Category.java 22 Nov 2004 16:43:39 -0000 1.93
@@ -32,6 +32,7 @@
package org.apache.log4j;
import org.apache.log4j.helpers.AppenderAttachableImpl;
+import org.apache.log4j.helpers.MessageFormatter;
import org.apache.log4j.helpers.NullEnumeration;
import org.apache.log4j.helpers.ReaderWriterLock;
import org.apache.log4j.spi.AppenderAttachable;
@@ -249,44 +250,6 @@
}
}
- /**
- * Log a message object with the [EMAIL PROTECTED] Level#TRACE TRACE}
level.
- *
- * @param message the message object to log.
- * @see #debug(Object) for an explanation of the logic applied.
- * @since 1.3
- */
- public void trace(Object message) {
- if (repository.isDisabled(Level.TRACE_INT)) {
- return;
- }
-
- if (Level.TRACE.isGreaterOrEqual(this.getEffectiveLevel())) {
- forcedLog(FQCN, Level.TRACE, message, null);
- }
- }
-
- /**
- * Log a message object with the <code>TRACE</code> level including the
- * stack trace of the [EMAIL PROTECTED] Throwable}<code>t</code> passed
as parameter.
- *
- * <p>
- * See [EMAIL PROTECTED] #debug(Object)} form for more detailed
information.
- * </p>
- *
- * @param message the message object to log.
- * @param t the exception to log, including its stack trace.
- */
- public void trace(Object message, Throwable t) {
- if (repository.isDisabled(Level.TRACE_INT)) {
- return;
- }
-
- if (Level.TRACE.isGreaterOrEqual(this.getEffectiveLevel())) {
- forcedLog(FQCN, Level.TRACE, message, t);
- }
- }
-
/**
* Log a message object with the [EMAIL PROTECTED] Level#DEBUG DEBUG}
level.
@@ -341,6 +304,39 @@
forcedLog(FQCN, Level.DEBUG, message, t);
}
}
+
+ /**
+ * Log a message with the <code>DEBUG</code> level with message formatting
+ * done according to the value of <code>messagePattern</code> and
+ * <code>arg</code> parameters.
+ * <p>
+ * This form avoids superflous parameter construction. Whenever possible,
+ * you should use this form instead of constructing the message parameter
+ * using string concatenation.
+ *
+ * @param messagePattern The message pattern which will be parsed and
formatted
+ * @param arg The argument to replace the formatting element, i,e,
+ * the '{}' pair within <code>messagePattern</code>.
+ * @since 1.3
+ */
+ public void debug(Object messagePattern, Object arg) {
+ if (repository.isDisabled(Level.DEBUG_INT)) {
+ return;
+ }
+
+ if (Level.DEBUG.isGreaterOrEqual(this.getEffectiveLevel())) {
+ if (messagePattern instanceof String){
+ String msgStr = (String) messagePattern;
+ msgStr = MessageFormatter.format(msgStr, arg);
+ forcedLog(FQCN, Level.DEBUG, msgStr, null);
+ } else {
+ // To be failsafe, we handle the case where 'messagePattern' is not
+ // a String. Unless the user makes a mistake, this should never
happen.
+ forcedLog(FQCN, Level.DEBUG, messagePattern, null);
+ }
+ }
+ }
+
/**
* Log a message object with the [EMAIL PROTECTED] Level#ERROR ERROR}
Level.
@@ -396,6 +392,38 @@
}
/**
+ * Log a message with the <code>ERROR</code> level with message formatting
+ * done according to the value of <code>messagePattern</code> and
+ * <code>arg</code> parameters.
+ * <p>
+ * This form avoids superflous parameter construction. Whenever possible,
+ * you should use this form instead of constructing the message parameter
+ * using string concatenation.
+ *
+ * @param messagePattern The message pattern which will be parsed and
formatted
+ * @param arg The argument to replace the formatting element, i,e,
+ * the '{}' pair within <code>messagePattern</code>.
+ * @since 1.3
+ */
+ public void error(Object messagePattern, Object arg) {
+ if (repository.isDisabled(Level.ERROR_INT)) {
+ return;
+ }
+
+ if (Level.ERROR.isGreaterOrEqual(this.getEffectiveLevel())) {
+ if (messagePattern instanceof String){
+ String msgStr = (String) messagePattern;
+ msgStr = MessageFormatter.format(msgStr, arg);
+ forcedLog(FQCN, Level.ERROR, msgStr, null);
+ } else {
+ // To be failsafe, we handle the case where 'messagePattern' is not
+ // a String. Unless the user makes a mistake, this should never
happen.
+ forcedLog(FQCN, Level.ERROR, messagePattern, null);
+ }
+ }
+ }
+
+ /**
* If the named category exists (in the default hierarchy) then it returns
a
* reference to the category, otherwise it returns <code>null</code>.
*
@@ -436,6 +464,38 @@
forcedLog(FQCN, Level.FATAL, message, null);
}
}
+
+ /**
+ * Log a message with the <code>FATAL</code> level with message formatting
+ * done according to the value of <code>messagePattern</code> and
+ * <code>arg</code> parameters.
+ * <p>
+ * This form avoids superflous parameter construction. Whenever possible,
+ * you should use this form instead of constructing the message parameter
+ * using string concatenation.
+ *
+ * @param messagePattern The message pattern which will be parsed and
formatted
+ * @param arg The argument to replace the formatting element, i,e,
+ * the '{}' pair within <code>messagePattern</code>.
+ * @since 1.3
+ */
+ public void fatal(Object messagePattern, Object arg) {
+ if (repository.isDisabled(Level.FATAL_INT)) {
+ return;
+ }
+
+ if (Level.FATAL.isGreaterOrEqual(this.getEffectiveLevel())) {
+ if (messagePattern instanceof String){
+ String msgStr = (String) messagePattern;
+ msgStr = MessageFormatter.format(msgStr, arg);
+ forcedLog(FQCN, Level.FATAL, msgStr, null);
+ } else {
+ // To be failsafe, we handle the case where 'messagePattern' is not
+ // a String. Unless the user makes a mistake, this should never
happen.
+ forcedLog(FQCN, Level.FATAL, messagePattern, null);
+ }
+ }
+ }
/**
* Log a message object with the <code>FATAL</code> level including the
@@ -738,6 +798,38 @@
}
/**
+ * Log a message with the <code>INFO</code> level with message formatting
+ * done according to the value of <code>messagePattern</code> and
+ * <code>arg</code> parameters.
+ * <p>
+ * This form avoids superflous parameter construction. Whenever possible,
+ * you should use this form instead of constructing the message parameter
+ * using string concatenation.
+ *
+ * @param messagePattern The message pattern which will be parsed and
formatted
+ * @param arg The argument to replace the formatting element, i,e,
+ * the '{}' pair within <code>messagePattern</code>.
+ * @since 1.3
+ */
+ public void info(Object messagePattern, Object arg) {
+ if (repository.isDisabled(Level.INFO_INT)) {
+ return;
+ }
+
+ if (Level.INFO.isGreaterOrEqual(this.getEffectiveLevel())) {
+ if (messagePattern instanceof String){
+ String msgStr = (String) messagePattern;
+ msgStr = MessageFormatter.format(msgStr, arg);
+ forcedLog(FQCN, Level.INFO, msgStr, null);
+ } else {
+ // To be failsafe, we handle the case where 'messagePattern' is not
+ // a String. Unless the user makes a mistake, this should never
happen.
+ forcedLog(FQCN, Level.INFO, messagePattern, null);
+ }
+ }
+ }
+
+ /**
* Log a message object with the <code>INFO</code> level including the
stack
* trace of the [EMAIL PROTECTED] Throwable}<code>t</code> passed as
parameter.
*
@@ -1193,6 +1285,37 @@
forcedLog(FQCN, Level.WARN, message, t);
}
}
-}
+
+ /**
+ * Log a message with the <code>WARN</code> level with message formatting
+ * done according to the value of <code>messagePattern</code> and
+ * <code>arg</code> parameters.
+ * <p>
+ * This form avoids superflous parameter construction. Whenever possible,
+ * you should use this form instead of constructing the message parameter
+ * using string concatenation.
+ *
+ * @param messagePattern The message pattern which will be parsed and
formatted
+ * @param arg The argument to replace the formatting element, i,e,
+ * the '{}' pair within <code>messagePattern</code>.
+ * @since 1.3
+ */
+ public void warn(Object messagePattern, Object arg) {
+ if (repository.isDisabled(Level.WARN_INT)) {
+ return;
+ }
+ if (Level.WARN.isGreaterOrEqual(this.getEffectiveLevel())) {
+ if (messagePattern instanceof String){
+ String msgStr = (String) messagePattern;
+ msgStr = MessageFormatter.format(msgStr, arg);
+ forcedLog(FQCN, Level.WARN, msgStr, null);
+ } else {
+ // To be failsafe, we handle the case where 'messagePattern' is not
+ // a String. Unless the user makes a mistake, this should never
happen.
+ forcedLog(FQCN, Level.WARN, messagePattern, null);
+ }
+ }
+ }
+}
// End of class: Category.java
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]