[slf4j-dev] svn commit: r429 - in slf4j/trunk: . src/filtered-java/org/slf4j/impl src/java/org/slf4j src/java/org/slf4j/impl src/java/org/slf4j/spi tests
ceki at slf4j.org
ceki at slf4j.org
Mon Nov 21 15:59:21 CET 2005
Author: ceki
Date: Mon Nov 21 15:59:19 2005
New Revision: 429
Modified:
slf4j/trunk/build.xml
slf4j/trunk/src/filtered-java/org/slf4j/impl/StaticMarkerBinder.java
slf4j/trunk/src/java/org/slf4j/LoggerFactory.java
slf4j/trunk/src/java/org/slf4j/impl/SimpleLoggerFactory.java
slf4j/trunk/src/java/org/slf4j/impl/Util.java
slf4j/trunk/src/java/org/slf4j/spi/LoggerFactoryBinder.java
slf4j/trunk/tests/build.xml
Log:
Various minor changes in an effort to reduce jar file size.
Modified: slf4j/trunk/build.xml
==============================================================================
--- slf4j/trunk/build.xml (original)
+++ slf4j/trunk/build.xml Mon Nov 21 15:59:19 2005
@@ -155,13 +155,12 @@
<param name="IMPL" value="${IMPL}" />
</antcall>
- <jar jarfile="${jar-name}" basedir="${tmp.javac.dest}" includes="${SLF4J_STEM}/Constants.class,
+ <jar jarfile="${jar-name}" basedir="${tmp.javac.dest}" includes="
${SLF4J_STEM}/ILoggerFactory.class,
${SLF4J_STEM}/Logger*.class,
${SLF4J_STEM}/spi/LoggerFactoryBinder.class,
${SLF4J_STEM}/impl/MessageFormatter.class,
${SLF4J_STEM}/impl/Util.class,
- ${SLF4J_STEM}/impl/SystemPropBinder.class,
${SLF4J_STEM}/impl/StaticLoggerBinder.class,
${SLF4J_STEM}/impl/${IMPL}*.class">
<manifest>
Modified: slf4j/trunk/src/filtered-java/org/slf4j/impl/StaticMarkerBinder.java
==============================================================================
--- slf4j/trunk/src/filtered-java/org/slf4j/impl/StaticMarkerBinder.java (original)
+++ slf4j/trunk/src/filtered-java/org/slf4j/impl/StaticMarkerBinder.java Mon Nov 21 15:59:19 2005
@@ -53,7 +53,9 @@
* The unique instance of this class.
*/
public static final StaticMarkerBinder SINGLETON = new StaticMarkerBinder();
-
+
+ final IMarkerFactory markerFactory = new BasicMarkerFactory();
+
private StaticMarkerBinder() {
}
@@ -62,7 +64,7 @@
* {@link BasicMarkerFactory}.
*/
public IMarkerFactory getMarkerFactory() {
- return new BasicMarkerFactory();
+ return markerFactory;
}
/**
Modified: slf4j/trunk/src/java/org/slf4j/LoggerFactory.java
==============================================================================
--- slf4j/trunk/src/java/org/slf4j/LoggerFactory.java (original)
+++ slf4j/trunk/src/java/org/slf4j/LoggerFactory.java Mon Nov 21 15:59:19 2005
@@ -32,9 +32,7 @@
*/
package org.slf4j;
-
import org.slf4j.impl.StaticLoggerBinder;
-import org.slf4j.impl.SystemPropBinder;
import org.slf4j.impl.Util;
// WARNING
@@ -43,59 +41,46 @@
// WARNING
/**
- * The <code>LoggerFactory</code> is a utility class producing Loggers
- * for various logging APIs, most notably for NLOG4J and JDK 1.4 logging.
- * Other implemenations such as {@link org.slf4j.impl.NOPLogger NOPLogger} and
+ * The <code>LoggerFactory</code> is a utility class producing Loggers for
+ * various logging APIs, most notably for NLOG4J and JDK 1.4 logging. Other
+ * implemenations such as {@link org.slf4j.impl.NOPLogger NOPLogger} and
* {@link org.slf4j.impl.SimpleLogger SimpleLogger} are also supported.
- *
- * <p><code>LoggerFactory</code> is essentially a wrapper around an
- * {@link ILoggerFactory} instance bound with <code>LoggerFactory</code>
- * at compile time.
*
- * <p>Please note that all methods in <code>LoggerFactory</code> are
- * static.
+ * <p>
+ * <code>LoggerFactory</code> is essentially a wrapper around an
+ * {@link ILoggerFactory} instance bound with <code>LoggerFactory</code> at
+ * compile time.
+ *
+ * <p>
+ * Please note that all methods in <code>LoggerFactory</code> are static.
*
* @author <a href="http://www.qos.ch/log4j/">Ceki Gülcü</a>
*/
public final class LoggerFactory {
-
+
static ILoggerFactory loggerFactory;
// private constructor prevents instantiation
private LoggerFactory() {
}
-
- //
- // WARNING Do not modify copies but the original in
- // $SLF4J_HOME/src/filtered-java/org/slf4j/
- //
- static {
-
- loggerFactory = new SystemPropBinder().getLoggerFactory();
- // if could get an adapter from the system properties, bind dynamically
- if (loggerFactory != null) {
- System.out.println("However, SLF4J will use ["+loggerFactory.getClass().getName()
- + "] adapter factory from system properties.");
- } else {
- try { // otherwise bind statically
- loggerFactory = StaticLoggerBinder.SINGLETON.getLoggerFactory();
- } catch (Exception e) {
- // we should never get here
- Util.reportFailure(
- "Could not instantiate instance of class [" + StaticLoggerBinder.SINGLETON.getLoggerFactoryClassStr() + "]",
- e);
- }
+
+ static {
+ try {
+ loggerFactory = StaticLoggerBinder.SINGLETON.getLoggerFactory();
+ } catch (Exception e) {
+ // we should never get here
+ Util.reportFailure("Failed to instantiate logger ["
+ + StaticLoggerBinder.SINGLETON.getLoggerFactoryClassStr() + "]", e);
}
}
-
-
/**
- * Return a logger named according to the name parameter using the
- * statically bound {@link ILoggerFactory} instance.
+ * Return a logger named according to the name parameter using the statically
+ * bound {@link ILoggerFactory} instance.
*
- * @param name The name of the logger.
+ * @param name
+ * The name of the logger.
* @return logger
*/
public static Logger getLogger(String name) {
@@ -103,21 +88,22 @@
}
/**
- * Return a logger named corresponding to the class passed as parameter,
- * using the statically bound {@link ILoggerFactory} instance.
+ * Return a logger named corresponding to the class passed as parameter, using
+ * the statically bound {@link ILoggerFactory} instance.
*
- * @param clazz the returned logger will be named after clazz
+ * @param clazz
+ * the returned logger will be named after clazz
* @return logger
*/
public static Logger getLogger(Class clazz) {
return loggerFactory.getLogger(clazz.getName());
}
-
+
/**
* Return the {@link ILoggerFactory} instance in use.
*
- * <p>Usually, the ILoggerFactory instance is bound with this class
- * at compile time.
+ * <p>ILoggerFactory instance is bound with this class at compile
+ * time.
*
* @return the ILoggerFactory instance in use
*/
Modified: slf4j/trunk/src/java/org/slf4j/impl/SimpleLoggerFactory.java
==============================================================================
--- slf4j/trunk/src/java/org/slf4j/impl/SimpleLoggerFactory.java (original)
+++ slf4j/trunk/src/java/org/slf4j/impl/SimpleLoggerFactory.java Mon Nov 21 15:59:19 2005
@@ -59,11 +59,11 @@
* Return an appropriate {@link SimpleLogger} instance by name.
*/
public Logger getLogger(String name) {
- Logger ulogger = (Logger) map.get(name);
- if(ulogger == null) {
- ulogger = new SimpleLogger(name);
- map.put(name, ulogger);
+ Logger slogger = (Logger) map.get(name);
+ if(slogger == null) {
+ slogger = new SimpleLogger(name);
+ map.put(name, slogger);
}
- return ulogger;
+ return slogger;
}
}
Modified: slf4j/trunk/src/java/org/slf4j/impl/Util.java
==============================================================================
--- slf4j/trunk/src/java/org/slf4j/impl/Util.java (original)
+++ slf4j/trunk/src/java/org/slf4j/impl/Util.java Mon Nov 21 15:59:19 2005
@@ -42,9 +42,9 @@
*/
public class Util {
- static public void reportFailure(String msg, Throwable t) {
+ static final public void reportFailure(String msg, Throwable t) {
System.err.println(msg);
- System.err.println("Reported exception follows.");
+ System.err.println("Reported exception:");
t.printStackTrace();
}
}
Modified: slf4j/trunk/src/java/org/slf4j/spi/LoggerFactoryBinder.java
==============================================================================
--- slf4j/trunk/src/java/org/slf4j/spi/LoggerFactoryBinder.java (original)
+++ slf4j/trunk/src/java/org/slf4j/spi/LoggerFactoryBinder.java Mon Nov 21 15:59:19 2005
@@ -58,7 +58,7 @@
*
* <p>This method allows the developer to intterogate this binder's intention
* which may be different from the {@link ILoggerFactory} instance it is able to
- * yields in practice. The discrepency should only occur in case of errors.
+ * yield in practice. The discrepency should only occur in case of errors.
*
* @return the class name of the intended {@link ILoggerFactory} instance
*/
Modified: slf4j/trunk/tests/build.xml
==============================================================================
--- slf4j/trunk/tests/build.xml (original)
+++ slf4j/trunk/tests/build.xml Mon Nov 21 15:59:19 2005
@@ -160,8 +160,7 @@
InvokeLog4j12x,
InvokeLog4j1212,
InvokeLog4j13alpha7,
- InvokeNLOG4J12x,
- XLoggerBySystemProps,
+ InvokeNLOG4J12x,
InvokeJCL,
InvokeJCLWithNOP" />
More information about the slf4j-dev
mailing list