[slf4j-dev] svn commit: r659 - in slf4j/trunk: . log4j-over-slf4j/src/main/java/org/apache/log4j log4j-over-slf4j/src/test/java/org/apache/log4j slf4j-log4j12/src/main/java/org/slf4j/impl slf4j-site/src/site slf4j-site/src/site/xdocs
ceki at slf4j.org
ceki at slf4j.org
Sat Nov 4 22:03:33 CET 2006
Author: ceki
Date: Sat Nov 4 22:03:33 2006
New Revision: 659
Added:
slf4j/trunk/log4j-over-slf4j/src/main/java/org/apache/log4j/package.html
Modified:
slf4j/trunk/log4j-over-slf4j/src/main/java/org/apache/log4j/Log4jLoggerFactory.java
slf4j/trunk/log4j-over-slf4j/src/main/java/org/apache/log4j/Logger.java
slf4j/trunk/log4j-over-slf4j/src/test/java/org/apache/log4j/InvokeLog4jTest.java
slf4j/trunk/pom.xml
slf4j/trunk/slf4j-log4j12/src/main/java/org/slf4j/impl/Log4jLoggerAdapter.java
slf4j/trunk/slf4j-site/src/site/site.xml
slf4j/trunk/slf4j-site/src/site/xdocs/download.xml
slf4j/trunk/slf4j-site/src/site/xdocs/news.xml
Log:
- javadoc improvements
- minor fixes in preparation for the 1.1.0-RC0 release
- the resulting assembly should be named after $aversion not ${parent.version}
- o.a.log4j.Log4jLoggerFactory is now accessible to the same package (instead of public)
Modified: slf4j/trunk/log4j-over-slf4j/src/main/java/org/apache/log4j/Log4jLoggerFactory.java
==============================================================================
--- slf4j/trunk/log4j-over-slf4j/src/main/java/org/apache/log4j/Log4jLoggerFactory.java (original)
+++ slf4j/trunk/log4j-over-slf4j/src/main/java/org/apache/log4j/Log4jLoggerFactory.java Sat Nov 4 22:03:33 2006
@@ -27,7 +27,7 @@
*
* @author Sébastien Pennec
*/
-public class Log4jLoggerFactory {
+class Log4jLoggerFactory {
private static Hashtable log4jLoggers = new Hashtable();
Modified: slf4j/trunk/log4j-over-slf4j/src/main/java/org/apache/log4j/Logger.java
==============================================================================
--- slf4j/trunk/log4j-over-slf4j/src/main/java/org/apache/log4j/Logger.java (original)
+++ slf4j/trunk/log4j-over-slf4j/src/main/java/org/apache/log4j/Logger.java Sat Nov 4 22:03:33 2006
@@ -12,169 +12,196 @@
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
- */
+ */
package org.apache.log4j;
import org.slf4j.LoggerFactory;
+import org.slf4j.Marker;
+import org.slf4j.MarkerFactory;
/**
* <p>
- * This class is a re-implementation of the org.apache.log4j.Logger class. It
- * uses a org.slf4j.Logger object to delegate the actual logging to a
- * user-chosen implementation.
+ * This class is a minimal implementation of the origianl org.apache.log4j.Logger class
+ * delegating all calls to a {@link org.slf4j.Logger} instance, which in turn
+ * will delegate to a final logging system chosen by the user..
* </p>
+ *
* <p>
- * Its printing methods that are shared with the
- * org.slf4j.Logger interface redirect the logging requests to the
- * org.slf4j.Logger. Those methods are debug, info, warn and error. However, the
- * methods that are now present in the org.slf4j.Logger interface are not
- * implemented. Those are the trace and fatal methods.
- * </p>
+ * Log4j's <code>debug()</code>, <code>info()</code>, <code>warn()</code>,
+ * <code>error()</code> printing methods are directly mapped to
+ * their SLF4J equivalents. Log4j's <code>trace()</code> printing method is
+ * mapped to SLF4J's <code>debug()</code> method with a TRACE marker.
+ * Log4j's <code>fatal()</code> printing method is mapped to SLF4J's
+ * <code>error()</code> method with a FATAL marker.
*
* @author Sébastien Pennec
+ * @author Ceki Gülcü
*/
public class Logger {
- private String name;
+ private String name;
- private org.slf4j.Logger lbLogger;
+ private org.slf4j.Logger lbLogger;
- protected Logger(String name) {
- this.name = name;
- lbLogger = LoggerFactory.getLogger(name);
- }
-
- public static Logger getLogger(String name) {
- return Log4jLoggerFactory.getLogger(name);
- }
-
- public static Logger getLogger(Class clazz) {
- return getLogger(clazz.getName());
- }
-
- public static Logger getRootLogger() {
- return getLogger("root");
- }
-
- public String getName() {
- return name;
- }
-
- public boolean isDebugEnabled() {
- return lbLogger.isDebugEnabled();
- }
-
- public void debug(Object message) {
- /**
- * In the debug(Object message) method, as well as other printing methods,
- * we consider that the message passed as a parameter is a String. Object
- * that usually need an ObjectRenderer cannot be sent to these methods.
- */
- lbLogger.debug((String) message);
- }
-
- public void debug(Object message, Throwable t) {
- lbLogger.debug((String) message, t);
- }
-
- public void debug(Object messagePattern, Object arg) {
- lbLogger.debug((String) messagePattern, arg);
- }
-
- public void debug(Object messagePattern, Object arg1, Object arg2) {
- lbLogger.debug((String) messagePattern, arg1, arg2);
- }
-
- public boolean isInfoEnabled() {
- return lbLogger.isInfoEnabled();
- }
-
- public void info(Object message) {
- lbLogger.info((String) message);
- }
-
- public void info(Object message, Throwable t) {
- lbLogger.info((String) message, t);
- }
-
- public void info(Object messagePattern, Object arg) {
- lbLogger.info((String) messagePattern, arg);
- }
-
- public void info(Object messagePattern, Object arg1, Object arg2) {
- lbLogger.info((String) messagePattern, arg1, arg2);
- }
-
- public boolean isWarnEnabled() {
- return lbLogger.isWarnEnabled();
- }
-
- public void warn(Object message) {
- lbLogger.warn((String) message);
- }
-
- public void warn(Object message, Throwable t) {
- lbLogger.warn((String) message, t);
- }
-
- public void warn(Object messagePattern, Object arg) {
- lbLogger.warn((String) messagePattern, arg);
- }
-
- public void warn(Object messagePattern, Object arg1, Object arg2) {
- lbLogger.warn((String) messagePattern, arg1, arg2);
- }
-
- public boolean isErrorEnabled() {
- return lbLogger.isErrorEnabled();
- }
-
- public void error(Object message) {
- lbLogger.error((String) message);
- }
-
- public void error(Object message, Throwable t) {
- lbLogger.error((String) message, t);
- }
-
- public void error(Object messagePattern, Object arg) {
- lbLogger.error((String) messagePattern, arg);
- }
-
- public void error(Object messagePattern, Object arg1, Object arg2) {
- lbLogger.error((String) messagePattern, arg1, arg2);
- }
-
- // public void log(String fqcn, Level level, String message, Throwable t) {
- // //FIXME improve + complete impl.
- // Logger logger = getLogger(fqcn);
- // if (Level.DEBUG.equals(level)) {
- // logger.debug(message, t);
- // } else if (Level.INFO.equals(level)) {
- // logger.info(message, t);
- // } else if (Level.WARN.equals(level)) {
- // logger.info(message, t);
- // } else if (Level.ERROR.equals(level)) {
- // logger.info(message, t);
- // }
- // }
- //
- // public boolean isEnabledFor(Level level) {
- // //FIXME improve + complete impl.
- // if(Level.DEBUG.equals(level) && lbLogger.isDebugEnabled()) {
- // return true;
- // }
- // if(Level.INFO.equals(level) && lbLogger.isInfoEnabled()) {
- // return true;
- // }
- // if(Level.WARN.equals(level) && lbLogger.isWarnEnabled()) {
- // return true;
- // }
- // if(Level.ERROR.equals(level) && lbLogger.isErrorEnabled()) {
- // return true;
- // }
- // return false;
- // }
+ private static Marker TRACE_MARKER = MarkerFactory.getMarker("TRACE");
+ private static Marker FATAL_MARKER = MarkerFactory.getMarker("FATAL");
+ Logger(String name) {
+ this.name = name;
+ lbLogger = LoggerFactory.getLogger(name);
+ }
+
+ public static Logger getLogger(String name) {
+ return Log4jLoggerFactory.getLogger(name);
+ }
+
+ public static Logger getLogger(Class clazz) {
+ return getLogger(clazz.getName());
+ }
+
+ /**
+ * Does the obvious.
+ * @return
+ */
+ public static Logger getRootLogger() {
+ return getLogger("root");
+ }
+
+ /**
+ * Returns the obvious.
+ * @return
+ */
+ public String getName() {
+ return name;
+ }
+
+ /**
+ * Delegates to {@link org.slf4j.Logger#isDebugEnabled} method of the SLF4J API,
+ * in addition, the call is marked with a marker named "TRACE".
+ */
+ public boolean isTraceEnabled() {
+ return lbLogger.isDebugEnabled(TRACE_MARKER);
+ }
+
+ /**
+ * Delegates to {@link org.slf4j.Logger#isDebugEnabled} method of the SLF4J API.
+ */
+ public boolean isDebugEnabled() {
+ return lbLogger.isDebugEnabled();
+ }
+
+ /**
+ * Delegates to {@link org.slf4j.Logger#isInfoEnabled} method of the SLF4J API.
+ */
+ public boolean isInfoEnabled() {
+ return lbLogger.isInfoEnabled();
+ }
+
+ /**
+ * Delegates to {@link org.slf4j.Logger#isWarnEnabled} method of the SLF4J API.
+ */
+ public boolean isWarnEnabled() {
+ return lbLogger.isWarnEnabled();
+ }
+
+ /**
+ * Delegates to {@link org.slf4j.Logger#isErrorEnabled} method of the SLF4J API.
+ */
+ public boolean isErrorEnabled() {
+ return lbLogger.isErrorEnabled();
+ }
+
+
+ /**
+ * Delegates to {@link org.slf4j.Logger#debug(String)} method of the SLF4J API,
+ * in addition, the call is marked with a marker named "TRACE".
+ */
+ public void trace(Object message) {
+ lbLogger.debug(TRACE_MARKER, (String) message);
+ }
+
+ /**
+ * Delegates to {@link org.slf4j.Logger#debug(String,Throwable)} method of the
+ * SLF4J API, in addition, the call is marked with a marker named "TRACE".
+ */
+ public void trace(Object message, Throwable t) {
+ lbLogger.debug(TRACE_MARKER, (String) message, t);
+ }
+
+ /**
+ * Delegates to {@link org.slf4j.Logger#debug(String)} method of the SLF4J API.
+ */
+ public void debug(Object message) {
+ // casting to String as SLF4J only accepts String instances, not Object
+ // instances.
+ lbLogger.debug((String) message);
+ }
+
+ /**
+ * Delegates to {@link org.slf4j.Logger#debug(String,Throwable)} method of the
+ * SLF4J API.
+ */
+ public void debug(Object message, Throwable t) {
+ lbLogger.debug((String) message, t);
+ }
+
+ /**
+ * Delegates to {@link org.slf4j.Logger#info(String)} method of the SLF4J API.
+ */
+ public void info(Object message) {
+ lbLogger.info((String) message);
+ }
+
+ /**
+ * Delegates to {@link org.slf4j.Logger#info(String, Throwable)} method of the
+ * SLF4J API.
+ */
+ public void info(Object message, Throwable t) {
+ lbLogger.info((String) message, t);
+ }
+
+ /**
+ * Delegates to {@link org.slf4j.Logger#warn(String)} method of the SLF4J API.
+ */
+ public void warn(Object message) {
+ lbLogger.warn((String) message);
+ }
+
+ /**
+ * Delegates to {@link org.slf4j.Logger#warn(String,Throwable)} method of the SLF4J API.
+ */
+ public void warn(Object message, Throwable t) {
+ lbLogger.warn((String) message, t);
+ }
+
+ /**
+ * Delegates to {@link org.slf4j.Logger#error(String)} method of the SLF4J API.
+ */
+ public void error(Object message) {
+ lbLogger.error((String) message);
+ }
+
+ /**
+ * Delegates to {@link org.slf4j.Logger#error(String,Throwable)} method of the SLF4J API.
+ */
+ public void error(Object message, Throwable t) {
+ lbLogger.error((String) message, t);
+ }
+
+ /**
+ * Delegates to {@link org.slf4j.Logger#error(String)} method of the
+ * SLF4J API, in addition, the call is marked with a marker named "FATAL".
+ */
+ public void fatal(Object message) {
+ lbLogger.error(FATAL_MARKER, (String) message);
+ }
+
+ /**
+ * Delegates to {@link org.slf4j.Logger#error(String,Throwable)} method of the
+ * SLF4J API, in addition, the call is marked with a marker named "FATAL".
+ */
+ public void fatal(Object message, Throwable t) {
+ lbLogger.error(FATAL_MARKER, (String) message, t);
+ }
}
Added: slf4j/trunk/log4j-over-slf4j/src/main/java/org/apache/log4j/package.html
==============================================================================
--- (empty file)
+++ slf4j/trunk/log4j-over-slf4j/src/main/java/org/apache/log4j/package.html Sat Nov 4 22:03:33 2006
@@ -0,0 +1,18 @@
+<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
+
+
+<html>
+ <head>
+ <title></title>
+ </head>
+
+
+ <body>
+
+ <p>An rather minimal but sufficient implementation redirecting all
+ calls to a log4j logger to a SLF4J logger.</p>
+
+ </body>
+</html>
+
+
Modified: slf4j/trunk/log4j-over-slf4j/src/test/java/org/apache/log4j/InvokeLog4jTest.java
==============================================================================
--- slf4j/trunk/log4j-over-slf4j/src/test/java/org/apache/log4j/InvokeLog4jTest.java (original)
+++ slf4j/trunk/log4j-over-slf4j/src/test/java/org/apache/log4j/InvokeLog4jTest.java Sat Nov 4 22:03:33 2006
@@ -41,12 +41,14 @@
* that belongs to the log4j-over-slf4j package
*
* @author Sébastien Pennec
+ * @author Ceki Gülcü
*/
public class InvokeLog4jTest extends TestCase {
public void testIsEnabledAPI() {
// assume that we are running over slf4j-simple
Logger log = Logger.getLogger(InvokeLog4jTest.class.getName());
+ assertFalse(log.isTraceEnabled());
assertFalse(log.isDebugEnabled());
assertTrue(log.isInfoEnabled());
assertTrue(log.isWarnEnabled());
Modified: slf4j/trunk/pom.xml
==============================================================================
--- slf4j/trunk/pom.xml (original)
+++ slf4j/trunk/pom.xml Sat Nov 4 22:03:33 2006
@@ -157,7 +157,7 @@
src/main/assembly/source.xml
</descriptor>
</descriptors>
- <finalName>slf4j-${project.version}</finalName>
+ <finalName>slf4j-${aversion}</finalName>
<appendAssemblyId>false</appendAssemblyId>
<outputDirectory>target/site/dist/</outputDirectory>
</configuration>
Modified: slf4j/trunk/slf4j-log4j12/src/main/java/org/slf4j/impl/Log4jLoggerAdapter.java
==============================================================================
--- slf4j/trunk/slf4j-log4j12/src/main/java/org/slf4j/impl/Log4jLoggerAdapter.java (original)
+++ slf4j/trunk/slf4j-log4j12/src/main/java/org/slf4j/impl/Log4jLoggerAdapter.java Sat Nov 4 22:03:33 2006
@@ -42,7 +42,9 @@
* A wrapper over {@link org.apache.log4j.Logger
* org.apache.log4j.Logger} in conformance with the {@link Logger}
* interface. Note that the logging levels mentioned in this class
- * refer to those defined in the {@link org.apache.log4j.Level} class.
+ * refer to those defined in the
+ * <a href="http://logging.apache.org/log4j/docs/api/org/apache/log4j/Level.html"><code>org.apache.log4j.Level</code></a>
+ * class.
* @author Ceki Gülcü
*/
Modified: slf4j/trunk/slf4j-site/src/site/site.xml
==============================================================================
--- slf4j/trunk/slf4j-site/src/site/site.xml (original)
+++ slf4j/trunk/slf4j-site/src/site/site.xml Sat Nov 4 22:03:33 2006
@@ -4,7 +4,7 @@
<skin>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-skin</artifactId>
- <version>1.1.0</version>
+ <version>1.1.0-RC0</version>
</skin>
<publishDate position="navigation-bottom" format="dd-MM-yyyy"/>
Modified: slf4j/trunk/slf4j-site/src/site/xdocs/download.xml
==============================================================================
--- slf4j/trunk/slf4j-site/src/site/xdocs/download.xml (original)
+++ slf4j/trunk/slf4j-site/src/site/xdocs/download.xml Sat Nov 4 22:03:33 2006
@@ -11,29 +11,17 @@
<h2>Latest official SLF4J version</h2>
- <p>Download version 1.0.2 including <i>full source code</i>,
+ <p>Download version 1.1.0-RC0 including <i>full source code</i>,
class files and documentation as
</p>
<ul>
- <li><a href="dist/slf4j-1.0.2.tar.gz"><b>slf4j-1.0.2.tar.gz</b></a> </li>
- <li><a href="dist/slf4j-1.0.2.zip"><b>slf4j-1.0.2.zip</b></a> </li>
+ <li><a href="dist/slf4j-1.1.0-RC0.tar.gz"><b>slf4j-1.1.0-RC0.tar.gz</b></a> </li>
+ <li><a href="dist/slf4j-1.1.0-RC0.zip"><b>slf4j-1.1.0-RC0.zip</b></a> </li>
</ul>
- <h2>Current development version</h2>
-
- <p>Download version 1.1.0-beta0 including <i>full source code</i>,
- class files and documentation as
- </p>
-
- <ul>
- <li><a href="dist/slf4j-1.1.0-beta0.tar.gz"><b>slf4j-1.1.0-beta0.tar.gz</b></a> </li>
- <li><a href="dist/slf4j-1.1.0-beta0.zip"><b>slf4j-1.1.0-beta0.zip</b></a> </li>
-
- </ul>
-
<h2>Previous versions</h2>
<p>Previous versions of SLF4J can be downloaded from the <A
Modified: slf4j/trunk/slf4j-site/src/site/xdocs/news.xml
==============================================================================
--- slf4j/trunk/slf4j-site/src/site/xdocs/news.xml (original)
+++ slf4j/trunk/slf4j-site/src/site/xdocs/news.xml Sat Nov 4 22:03:33 2006
@@ -19,15 +19,15 @@
<h3>November 4th, 2006 - Release of SLF4J 1.1.0-RC0</h3>
- <p>Given that release 1.1.0-beta0 consisted mainly of
- packaging-related changes which seem to work well, this release is
- marked as RC0.</p>
+ <p>This release consists of bug fixes. Moreover, since the major
+ packaging related changes in 1.1.0-beta0 seem to work well, this
+ release is marked as RC0.</p>
<p>Fixed the JDK 1.5 dependency for the SLF4J build, as reported by
Boris Unkel in <a
href="http://bugzilla.slf4j.org/show_bug.cgi?id=28">bug number
- 28</a>. SLF4J now explicitly declares a dependency on JDK 1.4 in
- its pom.xml file.
+ 28</a>. SLF4J now explicitly declares a dependency on JDK 1.4 in its
+ pom.xml file.
</p>
<p>Fixed an incorrect reference to the logback project in slf4j-api
@@ -36,6 +36,13 @@
29</a>.
</p>
+ <p>Fixed a syncroisation problem in factories of almost all SLF4J
+ bindings. This bug was reported independenly by Howard M. Lewis Ship
+ and Boris Unkel in bug reports <a
+ href="http://bugzilla.slf4j.org/show_bug.cgi?id=26">26</a> and
+ respectively <a
+ href="http://bugzilla.slf4j.org/show_bug.cgi?id=26">27</a>.
+ </p>
<hr noshade="noshade" size="1"/>
More information about the slf4j-dev
mailing list