Bug 42094: Final touches on initial pass on log4j 1.3 component project
git-svn-id: https://svn.apache.org/repos/asf/logging/sandbox/log4j/component@527689 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/pom.xml b/pom.xml
index c8aba3c..24ef261 100644
--- a/pom.xml
+++ b/pom.xml
@@ -21,7 +21,7 @@
<groupId>log4j</groupId>
<artifactId>apache-log4j-component</artifactId>
<packaging>jar</packaging>
- <version>1.0-SNAPSHOT</version>
+ <version>0.1-SNAPSHOT</version>
<name>apache-log4j-component</name>
<description>log4j 1.3 component framework</description>
<url>http://logging.apache.org</url>
@@ -29,7 +29,6 @@
<system>Bugzilla</system>
<url>http://issues.apache.org/bugzilla</url>
</issueManagement>
- <inceptionYear>1999</inceptionYear>
<mailingLists>
<mailingList>
<name>log4j-user</name>
@@ -54,13 +53,6 @@
</otherArchives>
</mailingList>
</mailingLists>
-<developers>
- <developer>
- <id>carnold</id>
- <name>Curt Arnold</name>
- <email>carnold@apache.org</email>
- </developer>
-</developers>
<licenses>
<license>
<name>Apache License, Version 2.0</name>
@@ -85,7 +77,7 @@
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
- <version>1.2.11</version>
+ <version>1.2.14</version>
</dependency>
</dependencies>
</plugin>
@@ -119,9 +111,6 @@
<plugin>
<artifactId>maven-pmd-plugin</artifactId>
</plugin>
- <!-- plugin>
- <artifactId>maven-clover-plugin</artifactId>
- </plugin -->
<plugin>
<artifactId>maven-javadoc-plugin</artifactId>
</plugin>
diff --git a/src/main/java/org/apache/log4j/ULogger.java b/src/main/java/org/apache/log4j/ULogger.java
new file mode 100644
index 0000000..83a6bb8
--- /dev/null
+++ b/src/main/java/org/apache/log4j/ULogger.java
@@ -0,0 +1,203 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.log4j;
+
+
+/**
+ * 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
+ */
+ public interface ULogger {
+
+
+ /**
+ * Is the logger instance enabled for the DEBUG level?
+ * @return true if debug is enabled.
+ */
+ boolean isDebugEnabled();
+
+ /**
+ * Log a message object with the DEBUG level.
+ * @param msg - the message object to be logged
+ */
+ void debug(Object msg);
+
+
+ /**
+ * 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
+ */
+ void debug(Object parameterizedMsg, Object param1);
+
+ /**
+ * 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
+ */
+ 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);
+
+}
diff --git a/src/main/java/org/apache/log4j/spi/ComponentBase.java b/src/main/java/org/apache/log4j/spi/ComponentBase.java
index 7f32183..b3bfbfe 100644
--- a/src/main/java/org/apache/log4j/spi/ComponentBase.java
+++ b/src/main/java/org/apache/log4j/spi/ComponentBase.java
@@ -17,6 +17,7 @@
package org.apache.log4j.spi;
import org.apache.log4j.ULogger;
+import org.apache.log4j.Logger;
/**
@@ -97,7 +98,12 @@
protected ULogger getLogger() {
if (logger == null) {
if (repository != null) {
- logger = repository.getLogger(this.getClass().getName());
+ Logger l = repository.getLogger(this.getClass().getName());
+ if (l instanceof ULogger) {
+ logger = (ULogger) l;
+ } else {
+ logger = new Log4JULogger(l);
+ }
} else {
logger = SimpleULogger.getLogger(this.getClass().getName());
}