[slf4j-dev] [GIT] SLF4J: Simple Logging Facade for Java branch master updated. v_1.7.1-14-g73af0c6

Gitbot git-noreply at pixie.qos.ch
Thu Oct 4 15:34:37 CEST 2012


This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "SLF4J: Simple Logging Facade for Java".

The branch, master has been updated
       via  73af0c60de69cf37fabaded3a635e1751250c4e8 (commit)
       via  6e7442f58fdd2165b676154b324b9e8d90aaee35 (commit)
       via  b1a5d650f4f78a0a2181c7883456fcf8054b623e (commit)
      from  461e0efd24a6875eee7950ad60c9117514fbba29 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
http://git.qos.ch/gitweb/?p=slf4j.git;a=commit;h=73af0c60de69cf37fabaded3a635e1751250c4e8
http://github.com/ceki/slf4j/commit/73af0c60de69cf37fabaded3a635e1751250c4e8

commit 73af0c60de69cf37fabaded3a635e1751250c4e8
Author: Christian Trutz <christian.trutz at belaso.de>
Date:   Thu Oct 4 14:58:32 2012 +0200

    Convert line delimiters to unix style (\n) and recover the ability to
    show useful diffs with older commits.
    
    Signed-off-by: Christian Trutz <christian.trutz at belaso.de>

diff --git a/log4j-over-slf4j/src/main/java/org/apache/log4j/Log4jLoggerFactory.java b/log4j-over-slf4j/src/main/java/org/apache/log4j/Log4jLoggerFactory.java
index 5ce8a99..a0e38c5 100644
--- a/log4j-over-slf4j/src/main/java/org/apache/log4j/Log4jLoggerFactory.java
+++ b/log4j-over-slf4j/src/main/java/org/apache/log4j/Log4jLoggerFactory.java
@@ -1,78 +1,78 @@
-/*
- * Copyright 2001-2004 The Apache Software Foundation.
- *
- * Licensed 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;
-
-import java.util.Hashtable;
-
-import org.apache.log4j.spi.LoggerFactory;
-import org.slf4j.helpers.Util;
-
-/**
- * This class is a factory that creates and maintains org.apache.log4j.Loggers
- * wrapping org.slf4j.Loggers.
- * 
- * It keeps a hashtable of all created org.apache.log4j.Logger instances so that
- * all newly created instances are not dulpicates of existing loggers.
- * 
- * @author Sébastien Pennec
- */
-class Log4jLoggerFactory {
-
-  // String, Logger
-  private static Hashtable log4jLoggers = new Hashtable();
-
-  private static final String LOG4J_DELEGATION_LOOP_URL = "http://www.slf4j.org/codes.html#log4jDelegationLoop";
-  
-  // check for delegation loops
-  static {
-    try {
-      Class.forName("org.slf4j.impl.Log4jLoggerFactory");
-      String part1 = "Detected both log4j-over-slf4j.jar AND slf4j-log4j12.jar on the class path, preempting StackOverflowError. ";
-      String part2 = "See also " + LOG4J_DELEGATION_LOOP_URL
-          + " for more details.";
-
-      Util.report(part1);
-      Util.report(part2);
-            throw new IllegalStateException(part1 + part2);
-    } catch (ClassNotFoundException e) {
-      // this is the good case
-    }
-  }
-
-  public static synchronized Logger getLogger(String name) {
-    if (log4jLoggers.containsKey(name)) {
-      return (org.apache.log4j.Logger) log4jLoggers.get(name);
-    } else {
-      Logger log4jLogger = new Logger(name);
-
-      log4jLoggers.put(name, log4jLogger);
-      return log4jLogger;
-    }
-  }
-  
-  public static synchronized Logger getLogger(String name, LoggerFactory loggerFactory) {
-	  if (log4jLoggers.containsKey(name)) {
-		  return (org.apache.log4j.Logger) log4jLoggers.get(name);
-	  } else {
-		  Logger log4jLogger = loggerFactory.makeNewLoggerInstance(name);
-
-		  log4jLoggers.put(name, log4jLogger);
-		  return log4jLogger;
-	  }
-  }
-
-}
+/*
+ * Copyright 2001-2004 The Apache Software Foundation.
+ *
+ * Licensed 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;
+
+import java.util.Hashtable;
+
+import org.apache.log4j.spi.LoggerFactory;
+import org.slf4j.helpers.Util;
+
+/**
+ * This class is a factory that creates and maintains org.apache.log4j.Loggers
+ * wrapping org.slf4j.Loggers.
+ * 
+ * It keeps a hashtable of all created org.apache.log4j.Logger instances so that
+ * all newly created instances are not dulpicates of existing loggers.
+ * 
+ * @author Sébastien Pennec
+ */
+class Log4jLoggerFactory {
+
+  // String, Logger
+  private static Hashtable log4jLoggers = new Hashtable();
+
+  private static final String LOG4J_DELEGATION_LOOP_URL = "http://www.slf4j.org/codes.html#log4jDelegationLoop";
+  
+  // check for delegation loops
+  static {
+    try {
+      Class.forName("org.slf4j.impl.Log4jLoggerFactory");
+      String part1 = "Detected both log4j-over-slf4j.jar AND slf4j-log4j12.jar on the class path, preempting StackOverflowError. ";
+      String part2 = "See also " + LOG4J_DELEGATION_LOOP_URL
+          + " for more details.";
+
+      Util.report(part1);
+      Util.report(part2);
+            throw new IllegalStateException(part1 + part2);
+    } catch (ClassNotFoundException e) {
+      // this is the good case
+    }
+  }
+
+  public static synchronized Logger getLogger(String name) {
+    if (log4jLoggers.containsKey(name)) {
+      return (org.apache.log4j.Logger) log4jLoggers.get(name);
+    } else {
+      Logger log4jLogger = new Logger(name);
+
+      log4jLoggers.put(name, log4jLogger);
+      return log4jLogger;
+    }
+  }
+  
+  public static synchronized Logger getLogger(String name, LoggerFactory loggerFactory) {
+	  if (log4jLoggers.containsKey(name)) {
+		  return (org.apache.log4j.Logger) log4jLoggers.get(name);
+	  } else {
+		  Logger log4jLogger = loggerFactory.makeNewLoggerInstance(name);
+
+		  log4jLoggers.put(name, log4jLogger);
+		  return log4jLogger;
+	  }
+  }
+
+}
diff --git a/log4j-over-slf4j/src/main/java/org/apache/log4j/Logger.java b/log4j-over-slf4j/src/main/java/org/apache/log4j/Logger.java
index cf9f605..6be9d24 100644
--- a/log4j-over-slf4j/src/main/java/org/apache/log4j/Logger.java
+++ b/log4j-over-slf4j/src/main/java/org/apache/log4j/Logger.java
@@ -1,84 +1,84 @@
-/*
- * Copyright 2001-2004 The Apache Software Foundation.
- *
- * Licensed 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;
-
-import org.apache.log4j.spi.LoggerFactory;
-import org.slf4j.spi.LocationAwareLogger;
-
-/**
- * <p>
- * This class is a minimal implementation of the original
- * <code>org.apache.log4j.Logger</code> class (as found in log4j 1.2) 
- * delegating all calls to a {@link org.slf4j.Logger} instance.
- * </p>
- *
- * @author Ceki Gülcü 
- * */
-public class Logger extends Category {
-  
-  private static final String LOGGER_FQCN = Logger.class.getName();
-  
-  protected Logger(String name) {
-    super(name);
-  }
-
-  public static Logger getLogger(String name) {
-    return Log4jLoggerFactory.getLogger(name);
-  }
-
-  public static Logger getLogger(String name, LoggerFactory loggerFactory) {
-	  return Log4jLoggerFactory.getLogger(name,loggerFactory);
-  }
-
-  public static Logger getLogger(Class clazz) {
-    return getLogger(clazz.getName());
-  }
-  
-  /**
-   * Does the obvious.
-   * 
-   * @return
-   */
-  public static Logger getRootLogger() {
-    return Log4jLoggerFactory.getLogger(org.slf4j.Logger.ROOT_LOGGER_NAME);
-  }
-
-  
-  /**
-   * Delegates to {@link org.slf4j.Logger#isTraceEnabled} 
-   * method of SLF4J.
-   */
-  public boolean isTraceEnabled() {
-    return slf4jLogger.isTraceEnabled();
-  }
-  
-  /**
-   * Delegates to {@link org.slf4j.Logger#trace(String)} method in SLF4J.
-   */
-  public void trace(Object message) {
-    differentiatedLog(null, LOGGER_FQCN, LocationAwareLogger.TRACE_INT, message, null);
-  }
-
-  /**
-   * Delegates to {@link org.slf4j.Logger#trace(String,Throwable)} 
-   * method in SLF4J.
-   */
-  public void trace(Object message, Throwable t) {
-    differentiatedLog(null, LOGGER_FQCN, LocationAwareLogger.TRACE_INT, message, null);
-  }
-
-}
+/*
+ * Copyright 2001-2004 The Apache Software Foundation.
+ *
+ * Licensed 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;
+
+import org.apache.log4j.spi.LoggerFactory;
+import org.slf4j.spi.LocationAwareLogger;
+
+/**
+ * <p>
+ * This class is a minimal implementation of the original
+ * <code>org.apache.log4j.Logger</code> class (as found in log4j 1.2) 
+ * delegating all calls to a {@link org.slf4j.Logger} instance.
+ * </p>
+ *
+ * @author Ceki Gülcü 
+ * */
+public class Logger extends Category {
+  
+  private static final String LOGGER_FQCN = Logger.class.getName();
+  
+  protected Logger(String name) {
+    super(name);
+  }
+
+  public static Logger getLogger(String name) {
+    return Log4jLoggerFactory.getLogger(name);
+  }
+
+  public static Logger getLogger(String name, LoggerFactory loggerFactory) {
+    return Log4jLoggerFactory.getLogger(name,loggerFactory);
+  }
+
+  public static Logger getLogger(Class clazz) {
+    return getLogger(clazz.getName());
+  }
+  
+  /**
+   * Does the obvious.
+   * 
+   * @return
+   */
+  public static Logger getRootLogger() {
+    return Log4jLoggerFactory.getLogger(org.slf4j.Logger.ROOT_LOGGER_NAME);
+  }
+
+  
+  /**
+   * Delegates to {@link org.slf4j.Logger#isTraceEnabled} 
+   * method of SLF4J.
+   */
+  public boolean isTraceEnabled() {
+    return slf4jLogger.isTraceEnabled();
+  }
+  
+  /**
+   * Delegates to {@link org.slf4j.Logger#trace(String)} method in SLF4J.
+   */
+  public void trace(Object message) {
+    differentiatedLog(null, LOGGER_FQCN, LocationAwareLogger.TRACE_INT, message, null);
+  }
+
+  /**
+   * Delegates to {@link org.slf4j.Logger#trace(String,Throwable)} 
+   * method in SLF4J.
+   */
+  public void trace(Object message, Throwable t) {
+    differentiatedLog(null, LOGGER_FQCN, LocationAwareLogger.TRACE_INT, message, null);
+  }
+
+}

http://git.qos.ch/gitweb/?p=slf4j.git;a=commit;h=6e7442f58fdd2165b676154b324b9e8d90aaee35
http://github.com/ceki/slf4j/commit/6e7442f58fdd2165b676154b324b9e8d90aaee35

commit 6e7442f58fdd2165b676154b324b9e8d90aaee35
Merge: 461e0ef b1a5d65
Author: Matt Bishop <matt at thebishops.org>
Date:   Sun Sep 30 07:37:40 2012 -0700

    Merge pull request #26 from mattbishop/master
    
    Fix for Bugzilla #274


http://git.qos.ch/gitweb/?p=slf4j.git;a=commit;h=b1a5d650f4f78a0a2181c7883456fcf8054b623e
http://github.com/ceki/slf4j/commit/b1a5d650f4f78a0a2181c7883456fcf8054b623e

commit b1a5d650f4f78a0a2181c7883456fcf8054b623e
Author: mbishop <matthew.bishop at elasticpath.com>
Date:   Fri Sep 28 11:20:04 2012 -0700

    Bugzilla #274.

diff --git a/osgi-over-slf4j/src/main/java/org/slf4j/osgi/logservice/impl/Activator.java b/osgi-over-slf4j/src/main/java/org/slf4j/osgi/logservice/impl/Activator.java
index c824f80..06d19f9 100644
--- a/osgi-over-slf4j/src/main/java/org/slf4j/osgi/logservice/impl/Activator.java
+++ b/osgi-over-slf4j/src/main/java/org/slf4j/osgi/logservice/impl/Activator.java
@@ -42,7 +42,10 @@ import org.osgi.service.log.LogService;
 /**
  * <code>Activator</code> implements a simple bundle that registers a
  * {@link LogServiceFactory} for the creation of {@link LogService} implementations.
-**/
+ *
+ * @author John Conlon
+ * @author Matt Bishop
+ **/
 public class Activator implements BundleActivator {
     /**
      *
@@ -53,8 +56,9 @@ public class Activator implements BundleActivator {
      * @throws Exception
      */
     public void start(BundleContext bundleContext) throws Exception {
+
         Properties props = new Properties();
-        props.put("description", "An slf4j implementation.");
+        props.put("description", "An SLF4J LogService implementation.");
         ServiceFactory factory = new LogServiceFactory();
         bundleContext.registerService(LogService.class.getName(), factory, props);
     }
@@ -69,6 +73,6 @@ public class Activator implements BundleActivator {
     public void stop(BundleContext bundleContext) throws Exception {
 
         // Note: It is not required that we remove the service here, since
-        // the framework will do it automatically anyway.
+        // the framework will do it automatically.
     }
 }
diff --git a/osgi-over-slf4j/src/main/java/org/slf4j/osgi/logservice/impl/LogServiceFactory.java b/osgi-over-slf4j/src/main/java/org/slf4j/osgi/logservice/impl/LogServiceFactory.java
index 66b1051..3de2e1c 100644
--- a/osgi-over-slf4j/src/main/java/org/slf4j/osgi/logservice/impl/LogServiceFactory.java
+++ b/osgi-over-slf4j/src/main/java/org/slf4j/osgi/logservice/impl/LogServiceFactory.java
@@ -42,13 +42,11 @@ import org.osgi.framework.ServiceRegistration;
  * @author John Conlon
  * @version $Rev$, $Date$
  */
-public class LogServiceFactory implements ServiceFactory
-{
+public class LogServiceFactory implements ServiceFactory {
     /* (non-Javadoc)
      * @see org.osgi.framework.ServiceFactory#getService(org.osgi.framework.Bundle, org.osgi.framework.ServiceRegistration)
      */
-    public Object getService( Bundle bundle, ServiceRegistration arg1 )
-    {
+    public Object getService(Bundle bundle, ServiceRegistration arg1) {
         return new LogServiceImpl(bundle);
     }
 
@@ -56,8 +54,7 @@ public class LogServiceFactory implements ServiceFactory
     /* (non-Javadoc)
      * @see org.osgi.framework.ServiceFactory#ungetService(org.osgi.framework.Bundle, org.osgi.framework.ServiceRegistration, java.lang.Object)
      */
-    public void ungetService( Bundle bundle, ServiceRegistration arg1, Object arg2 )
-    {
+    public void ungetService(Bundle bundle, ServiceRegistration arg1, Object arg2) {
         //nothing to do.
     }
 }
diff --git a/osgi-over-slf4j/src/main/java/org/slf4j/osgi/logservice/impl/LogServiceImpl.java b/osgi-over-slf4j/src/main/java/org/slf4j/osgi/logservice/impl/LogServiceImpl.java
index 4765575..30d5257 100644
--- a/osgi-over-slf4j/src/main/java/org/slf4j/osgi/logservice/impl/LogServiceImpl.java
+++ b/osgi-over-slf4j/src/main/java/org/slf4j/osgi/logservice/impl/LogServiceImpl.java
@@ -33,8 +33,8 @@
 package org.slf4j.osgi.logservice.impl;
 
 import org.osgi.framework.Bundle;
-import org.osgi.framework.Constants;
 import org.osgi.framework.ServiceReference;
+import org.osgi.framework.Version;
 import org.osgi.service.log.LogService;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -44,6 +44,7 @@ import org.slf4j.LoggerFactory;
  * Logger.
  *
  * @author John Conlon
+ * @author Matt Bishop
  */
 public class LogServiceImpl implements LogService {
 
@@ -51,15 +52,19 @@ public class LogServiceImpl implements LogService {
 
 	private final Logger delegate;
 
+
 	/**
 	 * Creates a new instance of LogServiceImpl.
 	 *
+	 * @param bundle The bundle to create a new LogService for.
 	 */
 	public LogServiceImpl(Bundle bundle) {
-		String name = (String) bundle.getHeaders().get(
-				Constants.BUNDLE_SYMBOLICNAME);
-		String version = (String) bundle.getHeaders().get(
-				Constants.BUNDLE_VERSION);
+
+		String name = bundle.getSymbolicName();
+		Version version = bundle.getVersion();
+		if (version == null) {
+			version = Version.emptyVersion;
+		}
 		delegate = LoggerFactory.getLogger(name + '.' + version);
 	}
 
@@ -69,6 +74,7 @@ public class LogServiceImpl implements LogService {
 	 * @see org.osgi.service.log.LogService#log(int, java.lang.String)
 	 */
 	public void log(int level, String message) {
+
 		switch (level) {
 		case LOG_DEBUG:
 			delegate.debug(message);
@@ -94,6 +100,7 @@ public class LogServiceImpl implements LogService {
 	 *      java.lang.Throwable)
 	 */
 	public void log(int level, String message, Throwable exception) {
+
 		switch (level) {
 		case LOG_DEBUG:
 			delegate.debug(message, exception);
@@ -154,6 +161,7 @@ public class LogServiceImpl implements LogService {
 	 * @return The formatted log message.
 	 */
 	private String createMessage(ServiceReference sr, String message) {
+
 		StringBuilder output = new StringBuilder();
 		if (sr != null) {
 			output.append('[').append(sr.toString()).append(']');
@@ -171,8 +179,7 @@ public class LogServiceImpl implements LogService {
 	 * @see org.osgi.service.log.LogService#log(org.osgi.framework.ServiceReference,
 	 *      int, java.lang.String, java.lang.Throwable)
 	 */
-	public void log(ServiceReference sr, int level, String message,
-			Throwable exception) {
+	public void log(ServiceReference sr, int level, String message, Throwable exception) {
 
 		switch (level) {
 		case LOG_DEBUG:

-----------------------------------------------------------------------

Summary of changes:
 .../java/org/apache/log4j/Log4jLoggerFactory.java  |  156 +++++++++---------
 .../src/main/java/org/apache/log4j/Logger.java     |  168 ++++++++++----------
 .../org/slf4j/osgi/logservice/impl/Activator.java  |   10 +-
 .../osgi/logservice/impl/LogServiceFactory.java    |    9 +-
 .../slf4j/osgi/logservice/impl/LogServiceImpl.java |   21 ++-
 5 files changed, 186 insertions(+), 178 deletions(-)


hooks/post-receive
-- 
SLF4J: Simple Logging Facade for Java


More information about the slf4j-dev mailing list