Merge pull request #71 from lsdeva/master
Update LICENSE.txt to be 2014
diff --git a/jcl-over-slf4j/src/main/java/org/apache/commons/logging/impl/SimpleLog.java b/jcl-over-slf4j/src/main/java/org/apache/commons/logging/impl/SimpleLog.java
index 89621be..765bca3 100644
--- a/jcl-over-slf4j/src/main/java/org/apache/commons/logging/impl/SimpleLog.java
+++ b/jcl-over-slf4j/src/main/java/org/apache/commons/logging/impl/SimpleLog.java
@@ -674,8 +674,8 @@
}
private static InputStream getResourceAsStream(final String name) {
- return (InputStream) AccessController.doPrivileged(new PrivilegedAction() {
- public Object run() {
+ return AccessController.doPrivileged(new PrivilegedAction<InputStream>() {
+ public InputStream run() {
ClassLoader threadCL = getContextClassLoader();
if (threadCL != null) {
diff --git a/slf4j-api/pom.xml b/slf4j-api/pom.xml
index 3f82888..a15a501 100644
--- a/slf4j-api/pom.xml
+++ b/slf4j-api/pom.xml
@@ -19,7 +19,12 @@
<url>http://www.slf4j.org</url>
<dependencies>
-
+ <dependency>
+ <groupId>com.google.code.findbugs</groupId>
+ <artifactId>jsr305</artifactId>
+ <version>2.0.1</version>
+ <optional>true</optional>
+ </dependency>
</dependencies>
<build>
diff --git a/slf4j-api/src/main/java/org/slf4j/ILoggerFactory.java b/slf4j-api/src/main/java/org/slf4j/ILoggerFactory.java
index 4b5eb27..ee0e61c 100644
--- a/slf4j-api/src/main/java/org/slf4j/ILoggerFactory.java
+++ b/slf4j-api/src/main/java/org/slf4j/ILoggerFactory.java
@@ -24,6 +24,8 @@
*/
package org.slf4j;
+import javax.annotation.Nonnull;
+
/**
* <code>ILoggerFactory</code> instances manufacture {@link Logger}
@@ -54,5 +56,6 @@
* @param name the name of the Logger to return
* @return a Logger instance
*/
- public Logger getLogger(String name);
+ @Nonnull
+ public Logger getLogger(@Nonnull String name);
}
diff --git a/slf4j-api/src/main/java/org/slf4j/LoggerFactory.java b/slf4j-api/src/main/java/org/slf4j/LoggerFactory.java
index 52081ca..b4808da 100644
--- a/slf4j-api/src/main/java/org/slf4j/LoggerFactory.java
+++ b/slf4j-api/src/main/java/org/slf4j/LoggerFactory.java
@@ -26,7 +26,14 @@
import java.io.IOException;
import java.net.URL;
-import java.util.*;
+import java.util.Arrays;
+import java.util.Enumeration;
+import java.util.Iterator;
+import java.util.LinkedHashSet;
+import java.util.List;
+import java.util.Set;
+
+import javax.annotation.Nonnull;
import org.slf4j.helpers.NOPLoggerFactory;
import org.slf4j.helpers.SubstituteLogger;
@@ -272,7 +279,8 @@
* @param name The name of the logger.
* @return logger
*/
- public static Logger getLogger(String name) {
+ @Nonnull
+ public static Logger getLogger(@Nonnull String name) {
ILoggerFactory iLoggerFactory = getILoggerFactory();
return iLoggerFactory.getLogger(name);
}
@@ -284,7 +292,8 @@
* @param clazz the returned logger will be named after clazz
* @return logger
*/
- public static Logger getLogger(Class clazz) {
+ @Nonnull
+ public static Logger getLogger(@Nonnull Class clazz) {
return getLogger(clazz.getName());
}
@@ -296,6 +305,7 @@
*
* @return the ILoggerFactory instance in use
*/
+ @Nonnull
public static ILoggerFactory getILoggerFactory() {
if (INITIALIZATION_STATE == UNINITIALIZED) {
INITIALIZATION_STATE = ONGOING_INITIALIZATION;
diff --git a/slf4j-api/src/main/java/org/slf4j/helpers/MessageFormatter.java b/slf4j-api/src/main/java/org/slf4j/helpers/MessageFormatter.java
index aa5081d..ba3fea6 100644
--- a/slf4j-api/src/main/java/org/slf4j/helpers/MessageFormatter.java
+++ b/slf4j-api/src/main/java/org/slf4j/helpers/MessageFormatter.java
@@ -180,6 +180,27 @@
final Object[] argArray) {
Throwable throwableCandidate = getThrowableCandidate(argArray);
+ return arrayFormat(messagePattern, argArray, throwableCandidate);
+ }
+
+ /**
+ * Same principle as the {@link #format(String, Object)} and
+ * {@link #format(String, Object, Object)} methods except that any number of
+ * arguments can be passed in an array.
+ *
+ * @param messagePattern
+ * The message pattern which will be parsed and formatted
+ * @param argArray
+ * An array of arguments to be substituted in place of formatting
+ * anchors
+ * @param t
+ * {@link Throwable} or {@code null} if not present
+ * @return The formatted message
+ */
+ final public static FormattingTuple arrayFormat(final String messagePattern,
+ final Object[] argArray, final Throwable t) {
+
+ Throwable throwableCandidate = t;
if (messagePattern == null) {
return new FormattingTuple(null, argArray, throwableCandidate);
diff --git a/slf4j-jdk14/src/main/java/org/slf4j/impl/JDK14LoggerAdapter.java b/slf4j-jdk14/src/main/java/org/slf4j/impl/JDK14LoggerAdapter.java
index 7b5ee09..e6e972e 100644
--- a/slf4j-jdk14/src/main/java/org/slf4j/impl/JDK14LoggerAdapter.java
+++ b/slf4j-jdk14/src/main/java/org/slf4j/impl/JDK14LoggerAdapter.java
@@ -648,7 +648,8 @@
// do not perform this check. See also
// http://bugzilla.slf4j.org/show_bug.cgi?id=90
if (logger.isLoggable(julLevel)) {
- log(callerFQCN, julLevel, message, t);
+ final FormattingTuple ft = MessageFormatter.arrayFormat(message, argArray, t);
+ log(callerFQCN, julLevel, ft.getMessage(), ft.getThrowable());
}
}
}
diff --git a/slf4j-log4j12/src/main/java/org/slf4j/impl/Log4jLoggerAdapter.java b/slf4j-log4j12/src/main/java/org/slf4j/impl/Log4jLoggerAdapter.java
index 6a5c97a..5143fd7 100644
--- a/slf4j-log4j12/src/main/java/org/slf4j/impl/Log4jLoggerAdapter.java
+++ b/slf4j-log4j12/src/main/java/org/slf4j/impl/Log4jLoggerAdapter.java
@@ -598,7 +598,8 @@
throw new IllegalStateException("Level number " + level
+ " is not recognized.");
}
- logger.log(callerFQCN, log4jLevel, msg, t);
+ final FormattingTuple ft = MessageFormatter.arrayFormat(msg, argArray, t);
+ logger.log(callerFQCN, log4jLevel, ft.getMessage(), ft.getThrowable());
}
}
diff --git a/slf4j-simple/src/main/java/org/slf4j/impl/SimpleLogger.java b/slf4j-simple/src/main/java/org/slf4j/impl/SimpleLogger.java
index 6a70ec5..18b395f 100644
--- a/slf4j-simple/src/main/java/org/slf4j/impl/SimpleLogger.java
+++ b/slf4j-simple/src/main/java/org/slf4j/impl/SimpleLogger.java
@@ -61,7 +61,7 @@
* <code>org.slf4j.simpleLogger.defaultLogLevel</code> will be used.</li>
*
* <li><code>org.slf4j.simpleLogger.showDateTime</code> - Set to <code>true</code> if you want the current date and
- * time to be included in output messages. Default is <code>true</code></li>
+ * time to be included in output messages. Default is <code>false</code></li>
*
* <li><code>org.slf4j.simpleLogger.dateTimeFormat</code> - The date and time format to be used in the output messages.
* The pattern describing the date and time format is defined by
@@ -233,9 +233,9 @@
private static void loadProperties() {
// Add props from the resource simplelogger.properties
- InputStream in = (InputStream) AccessController.doPrivileged(
- new PrivilegedAction() {
- public Object run() {
+ InputStream in = AccessController.doPrivileged(
+ new PrivilegedAction<InputStream>() {
+ public InputStream run() {
ClassLoader threadCL = Thread.currentThread().getContextClassLoader();
if (threadCL != null) {
return threadCL.getResourceAsStream(CONFIGURATION_FILE);
diff --git a/slf4j-simple/src/test/resources/simplelogger.properties b/slf4j-simple/src/test/resources/simplelogger.properties
index 8ab1740..208edac 100644
--- a/slf4j-simple/src/test/resources/simplelogger.properties
+++ b/slf4j-simple/src/test/resources/simplelogger.properties
@@ -4,7 +4,7 @@
# Default logging detail level for all instances of SimpleLogger.
# Must be one of ("trace", "debug", "info", "warn", or "error").
# If not specified, defaults to "info".
-#org.slf4j.simpleLogger.defaultLog=info
+#org.slf4j.simpleLogger.defaultLogLevel=info
# Logging detail level for a SimpleLogger instance named "xxxxx".
# Must be one of ("trace", "debug", "info", "warn", or "error").