Author: ceki
Date: Tue Aug 15 22:15:36 2006
New Revision: 610

Added:
   slf4j/trunk/slf4j-log4j12/
   slf4j/trunk/slf4j-log4j12/pom.xml
   slf4j/trunk/slf4j-log4j12/src/
   slf4j/trunk/slf4j-log4j12/src/main/
   slf4j/trunk/slf4j-log4j12/src/main/java/
   slf4j/trunk/slf4j-log4j12/src/main/java/org/
   slf4j/trunk/slf4j-log4j12/src/main/java/org/slf4j/
   slf4j/trunk/slf4j-log4j12/src/main/java/org/slf4j/LoggerFactory.java
   slf4j/trunk/slf4j-log4j12/src/main/java/org/slf4j/MarkerFactory.java
   slf4j/trunk/slf4j-log4j12/src/main/java/org/slf4j/impl/
   
slf4j/trunk/slf4j-log4j12/src/main/java/org/slf4j/impl/Log4jLoggerAdapter.java
   
slf4j/trunk/slf4j-log4j12/src/main/java/org/slf4j/impl/Log4jLoggerFactory.java
   
slf4j/trunk/slf4j-log4j12/src/main/java/org/slf4j/impl/StaticLoggerBinder.java
   
slf4j/trunk/slf4j-log4j12/src/main/java/org/slf4j/impl/StaticMarkerBinder.java
   slf4j/trunk/slf4j-log4j12/src/test/
   slf4j/trunk/slf4j-log4j12/src/test/java/
   slf4j/trunk/slf4j-log4j12/src/test/java/org/
   slf4j/trunk/slf4j-log4j12/src/test/java/org/slf4j/
   slf4j/trunk/slf4j-log4j12/src/test/java/org/slf4j/InvokingSLF4J.java
   slf4j/trunk/slf4j-log4j12/src/test/java/org/slf4j/impl/
Log:
Mavenizing of SLF4J, on going work

Added: slf4j/trunk/slf4j-log4j12/pom.xml
==============================================================================
--- (empty file)
+++ slf4j/trunk/slf4j-log4j12/pom.xml   Tue Aug 15 22:15:36 2006
@@ -0,0 +1,37 @@
+<project 
+ xmlns="http://maven.apache.org/POM/4.0.0"; 
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"; 
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 
http://maven.apache.org/maven-v4_0_0.xsd";>
+
+       <parent>
+               <groupId>org.slf4j</groupId>
+               <artifactId>slf4j</artifactId>
+               <version>1.1.0</version>
+       </parent>
+       
+       <modelVersion>4.0.0</modelVersion>
+
+       <groupId>org.slf4j</groupId>
+       <artifactId>slf4j-log4j12</artifactId>
+       <version>${parent.version}</version>
+       <packaging>jar</packaging>
+       <name>SLF4J LOG4J-12 Binding</name>
+
+       <url>http://www.slf4j.org</url>
+
+  <dependencies>
+         <dependency>
+      <groupId>org.slf4j</groupId>
+      <artifactId>slf4j-api</artifactId>
+      <version>${project.version}</version>
+               </dependency>
+
+    <dependency>
+      <groupId>log4j</groupId>
+      <artifactId>log4j</artifactId>
+      <version>1.2.13</version>
+               </dependency>
+  </dependencies>
+
+
+</project>
\ No newline at end of file

Added: slf4j/trunk/slf4j-log4j12/src/main/java/org/slf4j/LoggerFactory.java
==============================================================================
--- (empty file)
+++ slf4j/trunk/slf4j-log4j12/src/main/java/org/slf4j/LoggerFactory.java        
Tue Aug 15 22:15:36 2006
@@ -0,0 +1,108 @@
+/*
+ * Copyright (c) 2004-2005 SLF4J.ORG
+ * Copyright (c) 2004-2005 QOS.ch
+ *
+ * All rights reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to  deal in  the Software without  restriction, including
+ * without limitation  the rights to  use, copy, modify,  merge, publish,
+ * distribute, and/or sell copies of  the Software, and to permit persons
+ * to whom  the Software is furnished  to do so, provided  that the above
+ * copyright notice(s) and this permission notice appear in all copies of
+ * the  Software and  that both  the above  copyright notice(s)  and this
+ * permission notice appear in supporting documentation.
+ *
+ * THE  SOFTWARE IS  PROVIDED  "AS  IS", WITHOUT  WARRANTY  OF ANY  KIND,
+ * EXPRESS OR  IMPLIED, INCLUDING  BUT NOT LIMITED  TO THE  WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR  A PARTICULAR PURPOSE AND NONINFRINGEMENT
+ * OF  THIRD PARTY  RIGHTS. IN  NO EVENT  SHALL THE  COPYRIGHT  HOLDER OR
+ * HOLDERS  INCLUDED IN  THIS  NOTICE BE  LIABLE  FOR ANY  CLAIM, OR  ANY
+ * SPECIAL INDIRECT  OR CONSEQUENTIAL DAMAGES, OR  ANY DAMAGES WHATSOEVER
+ * RESULTING FROM LOSS  OF USE, DATA OR PROFITS, WHETHER  IN AN ACTION OF
+ * CONTRACT, NEGLIGENCE  OR OTHER TORTIOUS  ACTION, ARISING OUT OF  OR IN
+ * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ *
+ * Except as  contained in  this notice, the  name of a  copyright holder
+ * shall not be used in advertising or otherwise to promote the sale, use
+ * or other dealings in this Software without prior written authorization
+ * of the copyright holder.
+ *
+ */
+package org.slf4j;
+
+import org.slf4j.impl.StaticLoggerBinder;
+import org.slf4j.impl.Util;
+
+/**
+ * The <code>LoggerFactory</code> is a utility class producing Loggers for
+ * various logging APIs, most notably for NLOG4J and JDK 1.4 logging. Other
+ * implementations such as [EMAIL PROTECTED] org.slf4j.impl.NOPLogger 
NOPLogger} and
+ * [EMAIL PROTECTED] org.slf4j.impl.SimpleLogger SimpleLogger} are also 
supported.
+ * 
+ * <p>
+ * <code>LoggerFactory</code> is essentially a wrapper around an
+ * [EMAIL PROTECTED] ILoggerFactory} instance bound with 
<code>LoggerFactory</code> at
+ * compile time.
+ * 
+ * <p>
+ * Please note that all methods in <code>LoggerFactory</code> are static.
+ * 
+ * @author Ceki G&uuml;lc&uuml;
+ */
+public final class LoggerFactory {
+
+  static ILoggerFactory loggerFactory;
+
+  // private constructor prevents instantiation
+  private LoggerFactory() {
+  }
+
+
+  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 [EMAIL PROTECTED] ILoggerFactory} instance.
+   * 
+   * @param name
+   *          The name of the logger.
+   * @return logger
+   */
+  public static Logger getLogger(String name) {
+    return loggerFactory.getLogger(name);
+  }
+
+  /**
+   * Return a logger named corresponding to the class passed as parameter, 
using
+   * the statically bound [EMAIL PROTECTED] ILoggerFactory} instance.
+   * 
+   * @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 [EMAIL PROTECTED] ILoggerFactory} instance in use.
+   * 
+   * <p>ILoggerFactory instance is bound with this class at compile
+   * time.
+   * 
+   * @return the ILoggerFactory instance in use
+   */
+  public static ILoggerFactory getILoggerFactory() {
+    return loggerFactory;
+  }
+}

Added: slf4j/trunk/slf4j-log4j12/src/main/java/org/slf4j/MarkerFactory.java
==============================================================================
--- (empty file)
+++ slf4j/trunk/slf4j-log4j12/src/main/java/org/slf4j/MarkerFactory.java        
Tue Aug 15 22:15:36 2006
@@ -0,0 +1,89 @@
+/*
+ * Copyright (c) 2004-2005 SLF4J.ORG
+ *
+ * All rights reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to  deal in  the Software without  restriction, including
+ * without limitation  the rights to  use, copy, modify,  merge, publish,
+ * distribute, and/or sell copies of  the Software, and to permit persons
+ * to whom  the Software is furnished  to do so, provided  that the above
+ * copyright notice(s) and this permission notice appear in all copies of
+ * the  Software and  that both  the above  copyright notice(s)  and this
+ * permission notice appear in supporting documentation.
+ *
+ * THE  SOFTWARE IS  PROVIDED  "AS  IS", WITHOUT  WARRANTY  OF ANY  KIND,
+ * EXPRESS OR  IMPLIED, INCLUDING  BUT NOT LIMITED  TO THE  WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR  A PARTICULAR PURPOSE AND NONINFRINGEMENT
+ * OF  THIRD PARTY  RIGHTS. IN  NO EVENT  SHALL THE  COPYRIGHT  HOLDER OR
+ * HOLDERS  INCLUDED IN  THIS  NOTICE BE  LIABLE  FOR ANY  CLAIM, OR  ANY
+ * SPECIAL INDIRECT  OR CONSEQUENTIAL DAMAGES, OR  ANY DAMAGES WHATSOEVER
+ * RESULTING FROM LOSS  OF USE, DATA OR PROFITS, WHETHER  IN AN ACTION OF
+ * CONTRACT, NEGLIGENCE  OR OTHER TORTIOUS  ACTION, ARISING OUT OF  OR IN
+ * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ *
+ * Except as  contained in  this notice, the  name of a  copyright holder
+ * shall not be used in advertising or otherwise to promote the sale, use
+ * or other dealings in this Software without prior written authorization
+ * of the copyright holder.
+ *
+ */
+package org.slf4j;
+
+import org.slf4j.impl.StaticMarkerBinder;
+import org.slf4j.impl.Util;
+
+/**
+ * MarkerFactory is a utility class producing [EMAIL PROTECTED] Marker} 
instances as
+ * appropriate for the logging system currently in use.
+ * 
+ * <p>
+ * This class is essentially implemented as a wrapper around an
+ * [EMAIL PROTECTED] IMarkerFactory} instance bound at compile time.
+ * 
+ * <p>
+ * Please note that all methods in this class are static.
+ * 
+ * @author Ceki G&uuml;lc&uuml;
+ */
+public class MarkerFactory {
+  static IMarkerFactory markerFactory;
+
+  private MarkerFactory() {
+  }
+
+  static {
+    try {
+      markerFactory = StaticMarkerBinder.SINGLETON.getMarkerFactory();
+    } catch (Exception e) {
+      // we should never get here
+      Util.reportFailure("Could not instantiate instance of class ["
+          + StaticMarkerBinder.SINGLETON.getMarkerFactoryClassStr() + "]", e);
+    }
+  }
+
+  /**
+   * Return a Marker instance as specified by the name parameter using the
+   * previously bound [EMAIL PROTECTED] IMarkerFactory}instance.
+   * 
+   * @param name
+   *          The name of the [EMAIL PROTECTED] Marker} object to return.
+   * @return marker
+   */
+  public static Marker getMarker(String name) {
+    return markerFactory.getMarker(name);
+  }
+
+  /**
+   * Return the [EMAIL PROTECTED] IMarkerFactory}instance in use.
+   * 
+   * <p>The IMarkerFactory instance is usually bound with this class at 
+   * compile time.
+   * 
+   * @return the IMarkerFactory instance in use
+   */
+  public static IMarkerFactory getIMarkerFactory() {
+    return markerFactory;
+  }
+}
\ No newline at end of file

Added: 
slf4j/trunk/slf4j-log4j12/src/main/java/org/slf4j/impl/Log4jLoggerAdapter.java
==============================================================================
--- (empty file)
+++ 
slf4j/trunk/slf4j-log4j12/src/main/java/org/slf4j/impl/Log4jLoggerAdapter.java  
    Tue Aug 15 22:15:36 2006
@@ -0,0 +1,398 @@
+/*
+ * Copyright (c) 2004-2005 SLF4J.ORG
+ * Copyright (c) 2004-2005 QOS.ch
+ *
+ * All rights reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to  deal in  the Software without  restriction, including
+ * without limitation  the rights to  use, copy, modify,  merge, publish,
+ * distribute, and/or sell copies of  the Software, and to permit persons
+ * to whom  the Software is furnished  to do so, provided  that the above
+ * copyright notice(s) and this permission notice appear in all copies of
+ * the  Software and  that both  the above  copyright notice(s)  and this
+ * permission notice appear in supporting documentation.
+ *
+ * THE  SOFTWARE IS  PROVIDED  "AS  IS", WITHOUT  WARRANTY  OF ANY  KIND,
+ * EXPRESS OR  IMPLIED, INCLUDING  BUT NOT LIMITED  TO THE  WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR  A PARTICULAR PURPOSE AND NONINFRINGEMENT
+ * OF  THIRD PARTY  RIGHTS. IN  NO EVENT  SHALL THE  COPYRIGHT  HOLDER OR
+ * HOLDERS  INCLUDED IN  THIS  NOTICE BE  LIABLE  FOR ANY  CLAIM, OR  ANY
+ * SPECIAL INDIRECT  OR CONSEQUENTIAL DAMAGES, OR  ANY DAMAGES WHATSOEVER
+ * RESULTING FROM LOSS  OF USE, DATA OR PROFITS, WHETHER  IN AN ACTION OF
+ * CONTRACT, NEGLIGENCE  OR OTHER TORTIOUS  ACTION, ARISING OUT OF  OR IN
+ * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ *
+ * Except as  contained in  this notice, the  name of a  copyright holder
+ * shall not be used in advertising or otherwise to promote the sale, use
+ * or other dealings in this Software without prior written authorization
+ * of the copyright holder.
+ *
+ */
+
+package org.slf4j.impl;
+
+
+import org.apache.log4j.Level;
+import org.slf4j.Logger;
+
+
+/**
+ * A wrapper over [EMAIL PROTECTED] org.apache.log4j.Logger
+ * org.apache.log4j.Logger} in conformance with the [EMAIL PROTECTED] Logger}
+ * interface. Note that the logging levels mentioned in this class
+ * refer to those defined in the [EMAIL PROTECTED] org.apache.log4j.Level} 
class.
+
+ * @author Ceki G&uuml;lc&uuml;
+ */
+public final class Log4jLoggerAdapter extends MarkerIgnoringBase {
+  final org.apache.log4j.Logger logger;
+  
+  /**
+   * Following the pattern discussed in pages 162 through 168 of 
+   * "The complete log4j manual".
+   */
+  final static String FQCN = Log4jLoggerAdapter.class.getName();
+  
+  // WARN: Log4jLoggerAdapter constructor should have only package access so 
that
+  // only Log4jLoggerFactory be able to create one.
+  Log4jLoggerAdapter(org.apache.log4j.Logger logger) {
+    this.logger = logger;
+  }
+
+  public String getName() {
+   return logger.getName();
+  }
+  
+  /**
+   * Is this logger instance enabled for the DEBUG level?
+   *
+   * @return True if this Logger is enabled for level DEBUG, false
+   * otherwise.
+   */
+  public boolean isDebugEnabled() {
+    return logger.isDebugEnabled();
+  }
+
+
+  /**
+   * Log a message object at level DEBUG.
+   * @param msg - the message object to be logged
+   */
+  public void debug(String msg) {
+    logger.log(FQCN, Level.DEBUG, msg, null);
+  }
+
+  /**
+   * Log a message at level DEBUG according to the specified format and
+   * argument.
+   *
+   * <p>This form avoids superfluous object creation when the logger
+   * is disabled for level DEBUG. </p>
+   *
+   * @param format the format string
+   * @param arg  the argument
+   */
+  public void debug(String format, Object arg) {
+    if (logger.isDebugEnabled()) {
+      String msgStr = MessageFormatter.format(format, arg);
+      logger.log(FQCN, Level.DEBUG, msgStr, null);
+    }
+  }
+
+  /**
+   * Log a message at level DEBUG according to the specified format and
+   * arguments.
+   *
+   * <p>This form avoids superfluous object creation when the logger
+   * is disabled for the DEBUG level. </p>
+   *
+   * @param format the format string
+   * @param arg1  the first argument
+   * @param arg2  the second argument
+   */
+  public void debug(String format, Object arg1, Object arg2) {
+    if (logger.isDebugEnabled()) {
+      String msgStr = MessageFormatter.format(format, arg1, arg2);
+      logger.log(FQCN, Level.DEBUG, msgStr, null);
+    }
+  }
+  
+  /**
+   * Log a message at level DEBUG according to the specified format and
+   * arguments.
+   *
+   * <p>This form avoids superfluous object creation when the logger
+   * is disabled for the DEBUG level. </p>
+   *
+   * @param format the format string
+   * @param argArray an array of arguments
+   */
+  public void debug(String format, Object[] argArray) {
+    if (logger.isDebugEnabled()) {
+      String msgStr = MessageFormatter.arrayFormat(format, argArray);
+      logger.log(FQCN, Level.DEBUG, msgStr, null);
+    }
+  }
+
+  /**
+   * Log an exception (throwable) at  level DEBUG with an
+   * accompanying message.
+   *
+   * @param msg the message accompanying the exception
+   * @param t the exception (throwable) to log
+   */
+  public void debug(String msg, Throwable t) {
+    logger.log(FQCN, Level.DEBUG, msg, t);
+  }
+
+  /**
+   * Is this logger instance enabled for the INFO level?
+   *
+   * @return True if this Logger is enabled for the INFO level, false
+   * otherwise.
+   */
+  public boolean isInfoEnabled() {
+    return logger.isInfoEnabled();
+  }
+
+  /**
+   * Log a message object at the INFO level.
+   *
+   * @param msg - the message object to be logged
+   */
+  public void info(String msg) {
+    logger.log(FQCN, Level.INFO, msg, null);
+  }
+
+  /**
+   * Log a message at level INFO according to the specified format and
+   * argument.
+   *
+   * <p>This form avoids superfluous object creation when the logger
+   * is disabled for the INFO level. </p>
+   *
+   * @param format the format string
+   * @param arg  the argument
+   */
+  public void info(String format, Object arg) {
+    if (logger.isInfoEnabled()) {
+      String msgStr = MessageFormatter.format(format, arg);
+      logger.log(FQCN, Level.INFO, msgStr, null);
+    }
+  }
+
+  /**
+   * Log a message at the INFO level according to the specified format
+   * and arguments.
+   *
+   * <p>This form avoids superfluous object creation when the logger
+   * is disabled for the INFO level. </p>
+   *
+   * @param format the format string
+   * @param arg1  the first argument
+   * @param arg2  the second argument
+   */
+  public void info(String format, Object arg1, Object arg2) {
+    if (logger.isInfoEnabled()) {
+      String msgStr = MessageFormatter.format(format, arg1, arg2);
+      logger.log(FQCN, Level.INFO, msgStr, null);
+    }
+  }
+
+  /**
+   * Log a message at level INFO according to the specified format and
+   * arguments.
+   *
+   * <p>This form avoids superfluous object creation when the logger
+   * is disabled for the INFO level. </p>
+   *
+   * @param format the format string
+   * @param argArray an array of arguments
+   */
+  public void info(String format, Object[] argArray) {
+    if (logger.isInfoEnabled()) {
+      String msgStr = MessageFormatter.arrayFormat(format, argArray);
+      logger.log(FQCN, Level.INFO, msgStr, null);
+    }
+  }
+
+  /**
+   * Log an exception (throwable) at the INFO level with an
+   * accompanying message.
+   *
+   * @param msg the message accompanying the exception
+   * @param t the exception (throwable) to log
+   */
+  public void info(String msg, Throwable t) {
+    logger.log(FQCN, Level.INFO, msg, t);
+  }
+
+  /**
+   * Is this logger instance enabled for the WARN level?
+   *
+   * @return True if this Logger is enabled for the WARN level,
+   * false otherwise.
+   */
+  public boolean isWarnEnabled() {
+    return logger.isEnabledFor(Level.WARN);
+  }
+  
+  /**
+   * Log a message object at the WARN level.
+   *
+   * @param msg - the message object to be logged
+   */
+  public void warn(String msg) {
+    logger.log(FQCN, Level.WARN, msg, null);
+  }
+
+  /**
+   * Log a message at the WARN level according to the specified
+   * format and argument.
+   *
+   * <p>This form avoids superfluous object creation when the logger
+   * is disabled for the WARN level. </p>
+   *
+   * @param format the format string
+   * @param arg  the argument
+   */
+  public void warn(String format, Object arg) {
+    if (logger.isEnabledFor(Level.WARN)) {
+      String msgStr = MessageFormatter.format(format, arg);
+      logger.log(FQCN, Level.WARN, msgStr, null);
+    }
+  }
+
+  /**
+   * Log a message at the WARN level according to the specified
+   * format and arguments.
+   *
+   * <p>This form avoids superfluous object creation when the logger
+   * is disabled for the WARN level. </p>
+   *
+   * @param format the format string
+   * @param arg1  the first argument
+   * @param arg2  the second argument
+   */
+  public void warn(String format, Object arg1, Object arg2) {
+    if (logger.isEnabledFor(Level.WARN)) {
+      String msgStr = MessageFormatter.format(format, arg1, arg2);
+      logger.log(FQCN, Level.WARN, msgStr, null);
+    }
+  }
+
+  /**
+   * Log a message at level WARN according to the specified format and
+   * arguments.
+   *
+   * <p>This form avoids superfluous object creation when the logger
+   * is disabled for the WARN level. </p>
+   *
+   * @param format the format string
+   * @param argArray an array of arguments
+   */
+  public void warn(String format, Object[] argArray) {
+    if (logger.isEnabledFor(Level.WARN)) {
+      String msgStr = MessageFormatter.arrayFormat(format, argArray);
+      logger.log(FQCN, Level.WARN, msgStr, null);
+    }
+  }
+
+  
+  /**
+   * Log an exception (throwable) at the WARN level with an
+   * accompanying message.
+   *
+   * @param msg the message accompanying the exception
+   * @param t the exception (throwable) to log
+   */
+  public void warn(String msg, Throwable t) {
+    logger.log(FQCN, Level.WARN, msg, t);
+  }
+
+  /**
+   * Is this logger instance enabled for level ERROR?
+   *
+   * @return True if this Logger is enabled for level ERROR, false
+   * otherwise.
+   */
+  public boolean isErrorEnabled() {
+    return logger.isEnabledFor(Level.ERROR);
+  }
+
+  /**
+   * Log a message object at the ERROR level.
+   *
+   * @param msg - the message object to be logged
+   */
+  public void error(String msg) {
+    logger.log(FQCN, Level.ERROR, msg, null);
+  }
+
+  /**
+   * Log a message at the ERROR level according to the specified
+   * format and argument.
+   *
+   * <p>This form avoids superfluous object creation when the logger
+   * is disabled for the ERROR level. </p>
+   *
+   * @param format the format string
+   * @param arg  the argument
+   */
+  public void error(String format, Object arg) {
+    if (logger.isEnabledFor(Level.ERROR)) {
+      String msgStr = MessageFormatter.format(format, arg);
+      logger.log(FQCN, Level.ERROR, msgStr, null);
+    }
+  }
+
+  /**
+   * Log a message at the ERROR level according to the specified
+   * format and arguments.
+   *
+   * <p>This form avoids superfluous object creation when the logger
+   * is disabled for the ERROR level. </p>
+   *
+   * @param format the format string
+   * @param arg1  the first argument
+   * @param arg2  the second argument
+   */
+  public void error(String format, Object arg1, Object arg2) {
+    if (logger.isEnabledFor(Level.ERROR)) {
+      String msgStr = MessageFormatter.format(format, arg1, arg2);
+      logger.log(FQCN, Level.ERROR, msgStr, null);
+    }
+  }
+
+  /**
+   * Log a message at level ERROR according to the specified format and
+   * arguments.
+   *
+   * <p>This form avoids superfluous object creation when the logger
+   * is disabled for the ERROR level. </p>
+   *
+   * @param format the format string
+   * @param argArray an array of arguments
+   */
+  public void error(String format, Object[] argArray) {
+    if (logger.isEnabledFor(Level.ERROR)) {
+      String msgStr = MessageFormatter.arrayFormat(format, argArray);
+      logger.log(FQCN, Level.ERROR, msgStr, null);
+    }
+  }
+
+  
+  
+  /**
+   * Log an exception (throwable) at the ERROR level with an
+   * accompanying message.
+   *
+   * @param msg the message accompanying the exception
+   * @param t the exception (throwable) to log
+   */
+  public void error(String msg, Throwable t) {
+    logger.log(FQCN, Level.ERROR, msg, t);
+  }
+}

Added: 
slf4j/trunk/slf4j-log4j12/src/main/java/org/slf4j/impl/Log4jLoggerFactory.java
==============================================================================
--- (empty file)
+++ 
slf4j/trunk/slf4j-log4j12/src/main/java/org/slf4j/impl/Log4jLoggerFactory.java  
    Tue Aug 15 22:15:36 2006
@@ -0,0 +1,70 @@
+/* 
+ * Copyright (c) 2004-2005 SLF4J.ORG
+ * Copyright (c) 2004-2005 QOS.ch
+ *
+ * All rights reserved.
+ * 
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to  deal in  the Software without  restriction, including
+ * without limitation  the rights to  use, copy, modify,  merge, publish,
+ * distribute, and/or sell copies of  the Software, and to permit persons
+ * to whom  the Software is furnished  to do so, provided  that the above
+ * copyright notice(s) and this permission notice appear in all copies of
+ * the  Software and  that both  the above  copyright notice(s)  and this
+ * permission notice appear in supporting documentation.
+ * 
+ * THE  SOFTWARE IS  PROVIDED  "AS  IS", WITHOUT  WARRANTY  OF ANY  KIND,
+ * EXPRESS OR  IMPLIED, INCLUDING  BUT NOT LIMITED  TO THE  WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR  A PARTICULAR PURPOSE AND NONINFRINGEMENT
+ * OF  THIRD PARTY  RIGHTS. IN  NO EVENT  SHALL THE  COPYRIGHT  HOLDER OR
+ * HOLDERS  INCLUDED IN  THIS  NOTICE BE  LIABLE  FOR ANY  CLAIM, OR  ANY
+ * SPECIAL INDIRECT  OR CONSEQUENTIAL DAMAGES, OR  ANY DAMAGES WHATSOEVER
+ * RESULTING FROM LOSS  OF USE, DATA OR PROFITS, WHETHER  IN AN ACTION OF
+ * CONTRACT, NEGLIGENCE  OR OTHER TORTIOUS  ACTION, ARISING OUT OF  OR IN
+ * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ * 
+ * Except as  contained in  this notice, the  name of a  copyright holder
+ * shall not be used in advertising or otherwise to promote the sale, use
+ * or other dealings in this Software without prior written authorization
+ * of the copyright holder.
+ *
+ */
+
+package org.slf4j.impl;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.apache.log4j.LogManager;
+import org.slf4j.ILoggerFactory;
+import org.slf4j.Logger;
+
+/**
+ * Log4jLoggerFactory is an implementation of [EMAIL PROTECTED] ILoggerFactory}
+ * returning the appropriate named [EMAIL PROTECTED] Log4jLoggerAdapter} 
instance.
+ *
+ * @author Ceki G&uuml;lc&uuml;
+ */
+public class Log4jLoggerFactory implements ILoggerFactory {
+
+  // key: name (String), value: a Log4jLoggerAdapter;
+  Map loggerMap;
+
+  public Log4jLoggerFactory() {
+    loggerMap = new HashMap();
+  }
+
+  /* (non-Javadoc)
+   * @see org.slf4j.ILoggerFactory#getLogger(java.lang.String)
+   */
+  public Logger getLogger(String name) {
+    Logger slf4jLogger = (Logger) loggerMap.get(name);
+    if (slf4jLogger == null) {
+      org.apache.log4j.Logger logger = LogManager.getLogger(name);
+      slf4jLogger = new Log4jLoggerAdapter(logger);
+     loggerMap.put(name, slf4jLogger);
+    }
+    return slf4jLogger;
+  }
+}

Added: 
slf4j/trunk/slf4j-log4j12/src/main/java/org/slf4j/impl/StaticLoggerBinder.java
==============================================================================
--- (empty file)
+++ 
slf4j/trunk/slf4j-log4j12/src/main/java/org/slf4j/impl/StaticLoggerBinder.java  
    Tue Aug 15 22:15:36 2006
@@ -0,0 +1,78 @@
+/*
+ * Copyright (c) 2004-2005 SLF4J.ORG
+ * Copyright (c) 2004-2005 QOS.ch
+ *
+ * All rights reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to  deal in  the Software without  restriction, including
+ * without limitation  the rights to  use, copy, modify,  merge, publish,
+ * distribute, and/or sell copies of  the Software, and to permit persons
+ * to whom  the Software is furnished  to do so, provided  that the above
+ * copyright notice(s) and this permission notice appear in all copies of
+ * the  Software and  that both  the above  copyright notice(s)  and this
+ * permission notice appear in supporting documentation.
+ *
+ * THE  SOFTWARE IS  PROVIDED  "AS  IS", WITHOUT  WARRANTY  OF ANY  KIND,
+ * EXPRESS OR  IMPLIED, INCLUDING  BUT NOT LIMITED  TO THE  WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR  A PARTICULAR PURPOSE AND NONINFRINGEMENT
+ * OF  THIRD PARTY  RIGHTS. IN  NO EVENT  SHALL THE  COPYRIGHT  HOLDER OR
+ * HOLDERS  INCLUDED IN  THIS  NOTICE BE  LIABLE  FOR ANY  CLAIM, OR  ANY
+ * SPECIAL INDIRECT  OR CONSEQUENTIAL DAMAGES, OR  ANY DAMAGES WHATSOEVER
+ * RESULTING FROM LOSS  OF USE, DATA OR PROFITS, WHETHER  IN AN ACTION OF
+ * CONTRACT, NEGLIGENCE  OR OTHER TORTIOUS  ACTION, ARISING OUT OF  OR IN
+ * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ *
+ * Except as  contained in  this notice, the  name of a  copyright holder
+ * shall not be used in advertising or otherwise to promote the sale, use
+ * or other dealings in this Software without prior written authorization
+ * of the copyright holder.
+ *
+ */
+
+package org.slf4j.impl;
+
+import org.slf4j.ILoggerFactory;
+import org.slf4j.IMarkerFactory;
+import org.slf4j.LoggerFactory;
+import org.slf4j.MarkerFactory;
+import org.slf4j.spi.LoggerFactoryBinder;
+
+/**
+ * The binding of [EMAIL PROTECTED] LoggerFactory} class with an actual 
instance of 
+ * [EMAIL PROTECTED] ILoggerFactory} is performed using information returned 
by this class. 
+ * 
+ * <p>
+ * This class also contains the information for binding [EMAIL PROTECTED] 
MarkerFactory}
+ * with the appropriate [EMAIL PROTECTED] IMarkerFactory} instance.
+ * 
+ * @author Ceki G&uuml;lc&uuml;
+ */
+public class StaticLoggerBinder implements LoggerFactoryBinder {
+
+  /**
+   * The unique instance of this class.
+   */
+  public static final StaticLoggerBinder SINGLETON = new StaticLoggerBinder();
+  // Note: JCL gets substituted at build time by an appropriate Ant task
+  private static final String loggerFactoryClassStr = 
Log4jLoggerFactory.class.getName();
+
+  /** The ILoggerFactory instance returned by the [EMAIL PROTECTED] 
#getLoggerFactory} method
+   * should always be the same object
+   */
+  private final ILoggerFactory loggerFactory;
+  
+  private StaticLoggerBinder() {
+//  Note: JCL gets substituted at build time by an appropriate Ant task
+    loggerFactory = new Log4jLoggerFactory();
+  }
+  
+  public ILoggerFactory getLoggerFactory() {
+    return loggerFactory;
+  }
+  
+  public String getLoggerFactoryClassStr() {
+    return loggerFactoryClassStr;
+  }   
+}

Added: 
slf4j/trunk/slf4j-log4j12/src/main/java/org/slf4j/impl/StaticMarkerBinder.java
==============================================================================
--- (empty file)
+++ 
slf4j/trunk/slf4j-log4j12/src/main/java/org/slf4j/impl/StaticMarkerBinder.java  
    Tue Aug 15 22:15:36 2006
@@ -0,0 +1,76 @@
+/*
+ * Copyright (c) 2004-2005 SLF4J.ORG
+ * Copyright (c) 2004-2005 QOS.ch
+ *
+ * All rights reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to  deal in  the Software without  restriction, including
+ * without limitation  the rights to  use, copy, modify,  merge, publish,
+ * distribute, and/or sell copies of  the Software, and to permit persons
+ * to whom  the Software is furnished  to do so, provided  that the above
+ * copyright notice(s) and this permission notice appear in all copies of
+ * the  Software and  that both  the above  copyright notice(s)  and this
+ * permission notice appear in supporting documentation.
+ *
+ * THE  SOFTWARE IS  PROVIDED  "AS  IS", WITHOUT  WARRANTY  OF ANY  KIND,
+ * EXPRESS OR  IMPLIED, INCLUDING  BUT NOT LIMITED  TO THE  WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR  A PARTICULAR PURPOSE AND NONINFRINGEMENT
+ * OF  THIRD PARTY  RIGHTS. IN  NO EVENT  SHALL THE  COPYRIGHT  HOLDER OR
+ * HOLDERS  INCLUDED IN  THIS  NOTICE BE  LIABLE  FOR ANY  CLAIM, OR  ANY
+ * SPECIAL INDIRECT  OR CONSEQUENTIAL DAMAGES, OR  ANY DAMAGES WHATSOEVER
+ * RESULTING FROM LOSS  OF USE, DATA OR PROFITS, WHETHER  IN AN ACTION OF
+ * CONTRACT, NEGLIGENCE  OR OTHER TORTIOUS  ACTION, ARISING OUT OF  OR IN
+ * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ *
+ * Except as  contained in  this notice, the  name of a  copyright holder
+ * shall not be used in advertising or otherwise to promote the sale, use
+ * or other dealings in this Software without prior written authorization
+ * of the copyright holder.
+ *
+ */
+
+package org.slf4j.impl;
+
+import org.slf4j.IMarkerFactory;
+import org.slf4j.MarkerFactory;
+import org.slf4j.spi.MarkerFactoryBinder;
+
+/**
+ * 
+ * The binding of [EMAIL PROTECTED] MarkerFactory} class with an actual 
instance of 
+ * [EMAIL PROTECTED] IMarkerFactory} is performed using information returned 
by this class. 
+ * 
+ * @author Ceki G&uuml;lc&uuml;
+ */
+public class StaticMarkerBinder implements MarkerFactoryBinder {
+
+  /**
+   * The unique instance of this class.
+   */
+  public static final StaticMarkerBinder SINGLETON = new StaticMarkerBinder();
+  
+  final IMarkerFactory markerFactory = new BasicMarkerFactory();
+  
+  private StaticMarkerBinder() {
+  }
+  
+  /**
+   * Currently this method always returns an instance of 
+   * [EMAIL PROTECTED] BasicMarkerFactory}.
+   */
+  public IMarkerFactory getMarkerFactory() {
+    return markerFactory;
+  }
+  
+  /**
+   * Currently, this method returns the class name of
+   * [EMAIL PROTECTED] BasicMarkerFactory}.
+   */
+  public String getMarkerFactoryClassStr() {
+    return BasicMarkerFactory.class.getName();
+  }
+  
+  
+}

Added: slf4j/trunk/slf4j-log4j12/src/test/java/org/slf4j/InvokingSLF4J.java
==============================================================================
--- (empty file)
+++ slf4j/trunk/slf4j-log4j12/src/test/java/org/slf4j/InvokingSLF4J.java        
Tue Aug 15 22:15:36 2006
@@ -0,0 +1,121 @@
+/* 
+ * Copyright (c) 2004-2005 SLF4J.ORG
+ * Copyright (c) 2004-2005 QOS.CH
+ * 
+ * All rights reserved.
+ * 
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to  deal in  the Software without  restriction, including
+ * without limitation  the rights to  use, copy, modify,  merge, publish,
+ * distribute, and/or sell copies of  the Software, and to permit persons
+ * to whom  the Software is furnished  to do so, provided  that the above
+ * copyright notice(s) and this permission notice appear in all copies of
+ * the  Software and  that both  the above  copyright notice(s)  and this
+ * permission notice appear in supporting documentation.
+ * 
+ * THE  SOFTWARE IS  PROVIDED  "AS  IS", WITHOUT  WARRANTY  OF ANY  KIND,
+ * EXPRESS OR  IMPLIED, INCLUDING  BUT NOT LIMITED  TO THE  WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR  A PARTICULAR PURPOSE AND NONINFRINGEMENT
+ * OF  THIRD PARTY  RIGHTS. IN  NO EVENT  SHALL THE  COPYRIGHT  HOLDER OR
+ * HOLDERS  INCLUDED IN  THIS  NOTICE BE  LIABLE  FOR ANY  CLAIM, OR  ANY
+ * SPECIAL INDIRECT  OR CONSEQUENTIAL DAMAGES, OR  ANY DAMAGES WHATSOEVER
+ * RESULTING FROM LOSS  OF USE, DATA OR PROFITS, WHETHER  IN AN ACTION OF
+ * CONTRACT, NEGLIGENCE  OR OTHER TORTIOUS  ACTION, ARISING OUT OF  OR IN
+ * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ * 
+ * Except as  contained in  this notice, the  name of a  copyright holder
+ * shall not be used in advertising or otherwise to promote the sale, use
+ * or other dealings in this Software without prior written authorization
+ * of the copyright holder.
+ *
+ */
+
+package org.slf4j;
+
+import junit.framework.TestCase;
+
+
+/**
+ * Test whether invoking the SLF4J API causes problems or not.
+ * 
+ * @author Ceki Gulcu
+ *
+ */
+public class InvokingSLF4J extends TestCase {
+
+  public InvokingSLF4J (String arg0) {
+    super(arg0);
+  }
+
+  protected void setUp() throws Exception {
+    super.setUp();
+  }
+
+  protected void tearDown() throws Exception {
+    super.tearDown();
+  }
+  
+  public void test1() {
+    Logger logger = LoggerFactory.getLogger("test1");
+    logger.debug("Hello world.");
+  }
+  
+  public void test2() {
+    Integer i1 = new Integer(1);
+    Integer i2 = new Integer(2);
+    Integer i3 = new Integer(3);
+    Exception e = new Exception("This is a test exception.");
+    Logger logger = LoggerFactory.getLogger("test2");
+    
+    logger.debug("Hello world 1.");
+    logger.debug("Hello world {}", i1);
+    logger.debug("val={} val={}", i1, i2);
+    logger.debug("val={} val={} val={}", new Object[]{i1, i2, i3});
+    
+    logger.debug("Hello world 2", e);
+    logger.info("Hello world 2.");
+ 
+    
+    logger.warn("Hello world 3.");
+    logger.warn("Hello world 3", e);
+ 
+  
+    logger.error("Hello world 4.");
+    logger.error("Hello world {}", new Integer(3)); 
+    logger.error("Hello world 4.", e);
+  }
+  
+  public void testNull() {
+    Logger logger = LoggerFactory.getLogger("testNull");
+    logger.debug(null);
+    logger.info(null);
+    logger.warn(null);
+    logger.error(null);
+    
+    Exception e = new Exception("This is a test exception.");
+    logger.debug(null, e);
+    logger.info(null, e);
+    logger.warn(null, e);
+    logger.error(null, e);
+  }
+  
+  public void testMarker() {
+    Logger logger = LoggerFactory.getLogger("testMarker");
+    Marker blue = MarkerFactory.getMarker("BLUE");
+    logger.debug(blue, "hello");
+    logger.info(blue, "hello");
+    logger.warn(blue, "hello");
+    logger.error(blue, "hello");
+    
+    logger.debug(blue, "hello {}", "world");
+    logger.info(blue, "hello {}", "world");
+    logger.warn(blue, "hello {}", "world");
+    logger.error(blue, "hello {}", "world");
+
+    logger.debug(blue, "hello {} and {} ", "world", "universe");
+    logger.info(blue, "hello {} and {} ", "world", "universe");
+    logger.warn(blue, "hello {} and {} ", "world", "universe");
+    logger.error(blue, "hello {} and {} ", "world", "universe");
+  }
+}
_______________________________________________
dev mailing list
[email protected]
http://slf4j.org/mailman/listinfo/dev

Reply via email to