mirror of https://github.com/qos-ch/slf4j
commit
43bcc961a2
|
|
@ -43,7 +43,7 @@ public class SLF4JLocationAwareLog implements Log, Serializable {
|
|||
|
||||
// in both Log4jLogger and Jdk14Logger classes in the original JCL, the
|
||||
// logger instance is transient
|
||||
private transient LocationAwareLogger logger;
|
||||
private final transient LocationAwareLogger logger;
|
||||
|
||||
private static final String FQCN = SLF4JLocationAwareLog.class.getName();
|
||||
|
||||
|
|
|
|||
|
|
@ -42,7 +42,7 @@ public class SLF4JLog implements Log, Serializable {
|
|||
|
||||
// in both Log4jLogger and Jdk14Logger classes in the original JCL, the
|
||||
// logger instance is transient
|
||||
private transient Logger logger;
|
||||
private final transient Logger logger;
|
||||
|
||||
public SLF4JLog(Logger logger) {
|
||||
this.logger = logger;
|
||||
|
|
|
|||
|
|
@ -110,7 +110,7 @@ public class SLF4JLogFactory extends LogFactory {
|
|||
while (keys.hasMoreElements()) {
|
||||
names.add((String) keys.nextElement());
|
||||
}
|
||||
String results[] = new String[names.size()];
|
||||
String[] results = new String[names.size()];
|
||||
for (int i = 0; i < results.length; i++) {
|
||||
results[i] = (String) names.get(i);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -174,8 +174,8 @@ public class SLF4JBridgeHandler extends Handler {
|
|||
public static void removeHandlersForRootLogger() {
|
||||
java.util.logging.Logger rootLogger = getRootLogger();
|
||||
java.util.logging.Handler[] handlers = rootLogger.getHandlers();
|
||||
for (int i = 0; i < handlers.length; i++) {
|
||||
rootLogger.removeHandler(handlers[i]);
|
||||
for (Handler handler : handlers) {
|
||||
rootLogger.removeHandler(handler);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -45,12 +45,12 @@ public class Category {
|
|||
|
||||
private static final String CATEGORY_FQCN = Category.class.getName();
|
||||
|
||||
private String name;
|
||||
private final String name;
|
||||
|
||||
protected org.slf4j.Logger slf4jLogger;
|
||||
private org.slf4j.spi.LocationAwareLogger locationAwareLogger;
|
||||
|
||||
private static Marker FATAL_MARKER = MarkerFactory.getMarker("FATAL");
|
||||
private static final Marker FATAL_MARKER = MarkerFactory.getMarker("FATAL");
|
||||
|
||||
Category(String name) {
|
||||
this.name = name;
|
||||
|
|
|
|||
|
|
@ -33,7 +33,7 @@ import java.util.concurrent.ConcurrentMap;
|
|||
class Log4jLoggerFactory {
|
||||
|
||||
// String, Logger
|
||||
private static ConcurrentMap<String, Logger> log4jLoggers = new ConcurrentHashMap<>();
|
||||
private static final ConcurrentMap<String, Logger> log4jLoggers = new ConcurrentHashMap<>();
|
||||
|
||||
public static Logger getLogger(String name) {
|
||||
org.apache.log4j.Logger instance = log4jLoggers.get(name);
|
||||
|
|
|
|||
|
|
@ -182,7 +182,7 @@ public final class LoggerFactory {
|
|||
|
||||
// We need to use the name of the StaticLoggerBinder class, but we can't
|
||||
// reference the class itself.
|
||||
private static String STATIC_LOGGER_BINDER_PATH = "org/slf4j/impl/StaticLoggerBinder.class";
|
||||
private static final String STATIC_LOGGER_BINDER_PATH = "org/slf4j/impl/StaticLoggerBinder.class";
|
||||
|
||||
static Set<URL> findPossibleStaticLoggerBinderPathSet() {
|
||||
// use Set instead of list in order to deal with bug #138
|
||||
|
|
|
|||
|
|
@ -43,7 +43,7 @@ import java.util.*;
|
|||
*/
|
||||
public class BasicMDCAdapter implements MDCAdapter {
|
||||
|
||||
private InheritableThreadLocal<Map<String, String>> inheritableThreadLocal = new InheritableThreadLocal<Map<String, String>>() {
|
||||
private final InheritableThreadLocal<Map<String, String>> inheritableThreadLocal = new InheritableThreadLocal<Map<String, String>>() {
|
||||
@Override
|
||||
protected Map<String, String> childValue(Map<String, String> parentValue) {
|
||||
if (parentValue == null) {
|
||||
|
|
|
|||
|
|
@ -40,7 +40,7 @@ public class BasicMarker implements Marker {
|
|||
|
||||
private static final long serialVersionUID = -2849567615646933777L;
|
||||
private final String name;
|
||||
private List<Marker> referenceList = new CopyOnWriteArrayList<>();
|
||||
private final List<Marker> referenceList = new CopyOnWriteArrayList<>();
|
||||
|
||||
BasicMarker(String name) {
|
||||
if (name == null) {
|
||||
|
|
@ -128,9 +128,9 @@ public class BasicMarker implements Marker {
|
|||
return false;
|
||||
}
|
||||
|
||||
private static String OPEN = "[ ";
|
||||
private static String CLOSE = " ]";
|
||||
private static String SEP = ", ";
|
||||
private static final String OPEN = "[ ";
|
||||
private static final String CLOSE = " ]";
|
||||
private static final String SEP = ", ";
|
||||
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj)
|
||||
|
|
|
|||
|
|
@ -33,9 +33,9 @@ public class FormattingTuple {
|
|||
|
||||
static public FormattingTuple NULL = new FormattingTuple(null);
|
||||
|
||||
private String message;
|
||||
private Throwable throwable;
|
||||
private Object[] argArray;
|
||||
private final String message;
|
||||
private final Throwable throwable;
|
||||
private final Object[] argArray;
|
||||
|
||||
public FormattingTuple(String message) {
|
||||
this(message, null, null);
|
||||
|
|
|
|||
|
|
@ -14,9 +14,9 @@ public class NOP_FallbackServiceProvider implements SLF4JServiceProvider {
|
|||
// to avoid constant folding by the compiler, this field must *not* be final
|
||||
public static String REQUESTED_API_VERSION = "2.0.99"; // !final
|
||||
|
||||
private ILoggerFactory loggerFactory = new NOPLoggerFactory();
|
||||
private IMarkerFactory markerFactory = new BasicMarkerFactory();
|
||||
private MDCAdapter mdcAdapter = new NOPMDCAdapter();
|
||||
private final ILoggerFactory loggerFactory = new NOPLoggerFactory();
|
||||
private final IMarkerFactory markerFactory = new BasicMarkerFactory();
|
||||
private final MDCAdapter mdcAdapter = new NOPMDCAdapter();
|
||||
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -53,7 +53,7 @@ public class SubstituteLogger implements Logger {
|
|||
private Boolean delegateEventAware;
|
||||
private Method logMethodCache;
|
||||
private EventRecodingLogger eventRecodingLogger;
|
||||
private Queue<SubstituteLoggingEvent> eventQueue;
|
||||
private final Queue<SubstituteLoggingEvent> eventQueue;
|
||||
|
||||
public final boolean createdPostInitialization;
|
||||
|
||||
|
|
|
|||
|
|
@ -6,9 +6,9 @@ import org.slf4j.spi.MDCAdapter;
|
|||
import org.slf4j.spi.SLF4JServiceProvider;
|
||||
|
||||
public class SubstituteServiceProvider implements SLF4JServiceProvider {
|
||||
private SubstituteLoggerFactory loggerFactory = new SubstituteLoggerFactory();
|
||||
private IMarkerFactory markerFactory = new BasicMarkerFactory();
|
||||
private MDCAdapter mdcAdapter = new BasicMDCAdapter();
|
||||
private final SubstituteLoggerFactory loggerFactory = new SubstituteLoggerFactory();
|
||||
private final IMarkerFactory markerFactory = new BasicMarkerFactory();
|
||||
private final MDCAdapter mdcAdapter = new BasicMDCAdapter();
|
||||
|
||||
@Override
|
||||
public ILoggerFactory getLoggerFactory() {
|
||||
|
|
|
|||
|
|
@ -1,10 +1,12 @@
|
|||
package org.slf4j.spi;
|
||||
|
||||
import org.slf4j.event.LoggingEvent;
|
||||
|
||||
/**
|
||||
* Additional interface to {@link LoggingEventBuilder} and
|
||||
* {@link qorg.slf4j.event.LoggingEvent LoggingEvent}.
|
||||
* {@link org.slf4j.event.LoggingEvent LoggingEvent}.
|
||||
*
|
||||
* Implementations of {@link LoggingEventBuilder} and {@link LoggingEvent} may optionally
|
||||
* Implementations of {@link LoggingEventBuilder} and {@link LoggingEvent} may optionally
|
||||
* implement {@link CallerBoundaryAware} in order to support caller info extraction.
|
||||
*
|
||||
* This interface is intended for use by logging backends or logging bridges.
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@ package org.slf4j.spi;
|
|||
import org.slf4j.ILoggerFactory;
|
||||
import org.slf4j.IMarkerFactory;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.slf4j.MDC;
|
||||
|
||||
/**
|
||||
* This interface based on {@link java.util.ServiceLoader} paradigm.
|
||||
|
|
@ -31,7 +32,7 @@ public interface SLF4JServiceProvider {
|
|||
public IMarkerFactory getMarkerFactory();
|
||||
|
||||
/**
|
||||
* Return the instnace of {@link MDCAdapter} that
|
||||
* Return the instance of {@link MDCAdapter} that
|
||||
* {@link MDC} should bind to.
|
||||
*
|
||||
* @return instance of {@link MDCAdapter}
|
||||
|
|
|
|||
|
|
@ -29,7 +29,7 @@ import java.util.concurrent.CyclicBarrier;
|
|||
import java.util.concurrent.atomic.AtomicLong;
|
||||
|
||||
public class LoggerAccessingThread extends Thread {
|
||||
private static int LOOP_LEN = 32;
|
||||
private static final int LOOP_LEN = 32;
|
||||
|
||||
final CyclicBarrier barrier;
|
||||
final int count;
|
||||
|
|
|
|||
|
|
@ -36,7 +36,7 @@ import java.util.HashSet;
|
|||
import java.util.Set;
|
||||
|
||||
public class SubstituteLoggerFactoryTest {
|
||||
private SubstituteLoggerFactory factory = new SubstituteLoggerFactory();
|
||||
private final SubstituteLoggerFactory factory = new SubstituteLoggerFactory();
|
||||
|
||||
@Test
|
||||
public void testFactory() {
|
||||
|
|
|
|||
|
|
@ -135,8 +135,8 @@ public class LogTransformer implements ClassFileTransformer {
|
|||
}
|
||||
}
|
||||
|
||||
private String level;
|
||||
private String levelEnabled;
|
||||
private final String level;
|
||||
private final String levelEnabled;
|
||||
|
||||
private LogTransformer(Builder builder) {
|
||||
String s = "WARNING: javassist not available on classpath for javaagent, log statements will not be added";
|
||||
|
|
@ -156,10 +156,10 @@ public class LogTransformer implements ClassFileTransformer {
|
|||
this.levelEnabled = "is" + builder.level.substring(0, 1).toUpperCase() + builder.level.substring(1) + "Enabled";
|
||||
}
|
||||
|
||||
private boolean addEntryExit;
|
||||
private final boolean addEntryExit;
|
||||
// private boolean addVariableAssignment;
|
||||
private boolean verbose;
|
||||
private String[] ignore;
|
||||
private final boolean verbose;
|
||||
private final String[] ignore;
|
||||
|
||||
public byte[] transform(ClassLoader loader, String className, Class<?> clazz, ProtectionDomain domain, byte[] bytes) {
|
||||
|
||||
|
|
|
|||
|
|
@ -50,7 +50,7 @@ public class SortAndPruneComposites {
|
|||
int[] sortedArray = sort();
|
||||
// start a new stopwatch called PRUNE_COMPOSITES
|
||||
sortProfiler.start("PRUNE_COMPOSITES");
|
||||
int result[] = pruneComposites(sortedArray);
|
||||
int[] result = pruneComposites(sortedArray);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -39,7 +39,7 @@ import org.slf4j.spi.LoggingEventBuilder;
|
|||
*/
|
||||
class SLF4JPlatformLogger implements System.Logger {
|
||||
|
||||
static private String PRESUMED_CALLER_BOUNDARY = System.Logger.class.getName();
|
||||
static private final String PRESUMED_CALLER_BOUNDARY = System.Logger.class.getName();
|
||||
|
||||
private final Logger slf4jLogger;
|
||||
|
||||
|
|
|
|||
|
|
@ -52,7 +52,7 @@ public class SLF4JSystemLoggerFinder extends System.LoggerFinder {
|
|||
// is updated to forward a module, we should do that here.
|
||||
//
|
||||
// [1] https://openjdk.java.net/jeps/264
|
||||
SLF4JPlatformLogger adapter = platformLoggerFactory.getLogger(name);
|
||||
SLF4JPlatformLogger adapter = platformLoggerFactory.getLogger(name);
|
||||
return adapter;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -216,7 +216,7 @@ public final class JDK14LoggerAdapter extends LegacyAbstractLogger implements Lo
|
|||
static String SUBSTITUE = SubstituteLogger.class.getName();
|
||||
static String FLUENT = DefaultLoggingEventBuilder.class.getName();
|
||||
|
||||
static String BARRIER_CLASSES[] = new String[] { SUPER_OF_SUPER, SUPER, SELF, SUBSTITUE, FLUENT };
|
||||
static String[] BARRIER_CLASSES = new String[] { SUPER_OF_SUPER, SUPER, SELF, SUBSTITUE, FLUENT };
|
||||
|
||||
private boolean barrierMatch(String callerFQCN, String candidateClassName) {
|
||||
if (candidateClassName.equals(callerFQCN))
|
||||
|
|
|
|||
|
|
@ -47,7 +47,7 @@ public class LoggerSerializationTest {
|
|||
static class LoggerHolder implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private Logger log = LoggerFactory.getLogger(LoggerHolder.class);
|
||||
private final Logger log = LoggerFactory.getLogger(LoggerHolder.class);
|
||||
|
||||
public String toString() {
|
||||
return "log=" + getLog();
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ import org.junit.Test;
|
|||
|
||||
public class MDCFriendTest {
|
||||
|
||||
private static Random random = new Random();
|
||||
private static final Random random = new Random();
|
||||
int diff = random.nextInt(1024 * 8);
|
||||
|
||||
@Test
|
||||
|
|
|
|||
|
|
@ -58,8 +58,8 @@ public class MigratorFrame extends JFrame implements ActionListener {
|
|||
static final int X_SIZE = 700;
|
||||
static final int Y_SIZE = 400;
|
||||
|
||||
private SpringLayout layoutManager = new SpringLayout();
|
||||
private SpringLayoutHelper slh = new SpringLayoutHelper(layoutManager, BASIC_PADDING);
|
||||
private final SpringLayout layoutManager = new SpringLayout();
|
||||
private final SpringLayoutHelper slh = new SpringLayoutHelper(layoutManager, BASIC_PADDING);
|
||||
|
||||
private JLabel migrationLabel;
|
||||
|
||||
|
|
|
|||
|
|
@ -36,7 +36,7 @@ import java.util.regex.Pattern;
|
|||
*/
|
||||
public class JCLRuleSet implements RuleSet {
|
||||
|
||||
private ArrayList<ConversionRule> conversionRuleList;
|
||||
private final ArrayList<ConversionRule> conversionRuleList;
|
||||
|
||||
public JCLRuleSet() {
|
||||
// matching : import org.apache.commons.logging.LogFactory;
|
||||
|
|
|
|||
|
|
@ -36,7 +36,7 @@ import java.util.regex.Pattern;
|
|||
*/
|
||||
public class JULRuleSet implements RuleSet {
|
||||
|
||||
private ArrayList<ConversionRule> conversionRuleList;
|
||||
private final ArrayList<ConversionRule> conversionRuleList;
|
||||
|
||||
public JULRuleSet() {
|
||||
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@ import java.util.regex.Pattern;
|
|||
|
||||
public class Log4jRuleSet implements RuleSet {
|
||||
|
||||
private ArrayList<ConversionRule> conversionRuleList;
|
||||
private final ArrayList<ConversionRule> conversionRuleList;
|
||||
|
||||
public Log4jRuleSet() {
|
||||
|
||||
|
|
|
|||
|
|
@ -40,8 +40,8 @@ public class MultiGroupConversionRule implements ConversionRule {
|
|||
// our conversion reg-expressions
|
||||
final private static int MAX_GROUPS = 10;
|
||||
|
||||
private Pattern pattern;
|
||||
private String[] replacementTable = new String[MAX_GROUPS];
|
||||
private final Pattern pattern;
|
||||
private final String[] replacementTable = new String[MAX_GROUPS];
|
||||
|
||||
public MultiGroupConversionRule(Pattern pattern) {
|
||||
this.pattern = pattern;
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@ import java.util.Random;
|
|||
|
||||
public class RandomHelper {
|
||||
|
||||
private Random random = new Random(100);
|
||||
private final Random random = new Random(100);
|
||||
final char folderSeparator;
|
||||
|
||||
RandomHelper(char folderSeparator) {
|
||||
|
|
|
|||
|
|
@ -35,7 +35,7 @@ import org.slf4j.migrator.line.SingleConversionRule;
|
|||
|
||||
class TrivialMatcher implements RuleSet {
|
||||
|
||||
private ArrayList<ConversionRule> conversionRuleList;
|
||||
private final ArrayList<ConversionRule> conversionRuleList;
|
||||
|
||||
public TrivialMatcher() {
|
||||
// simple rule no capturing group is defined, we use default capturing group which is group zero
|
||||
|
|
|
|||
|
|
@ -17,9 +17,9 @@ public class NOPServiceProvider implements SLF4JServiceProvider {
|
|||
// to avoid constant folding by the compiler, this field must *not* be final
|
||||
public static String REQUESTED_API_VERSION = "2.0.99"; // !final
|
||||
|
||||
private ILoggerFactory loggerFactory = new NOPLoggerFactory();
|
||||
private IMarkerFactory markerFactory = new BasicMarkerFactory();
|
||||
private MDCAdapter mdcAdapter = new NOPMDCAdapter();
|
||||
private final ILoggerFactory loggerFactory = new NOPLoggerFactory();
|
||||
private final IMarkerFactory markerFactory = new BasicMarkerFactory();
|
||||
private final MDCAdapter mdcAdapter = new NOPMDCAdapter();
|
||||
|
||||
public ILoggerFactory getLoggerFactory() {
|
||||
return loggerFactory;
|
||||
|
|
|
|||
|
|
@ -45,7 +45,7 @@ public class MultithreadedInitializationTest {
|
|||
|
||||
final static int THREAD_COUNT = 4 + Runtime.getRuntime().availableProcessors() * 2;
|
||||
|
||||
private static AtomicLong EVENT_COUNT = new AtomicLong(0);
|
||||
private static final AtomicLong EVENT_COUNT = new AtomicLong(0);
|
||||
|
||||
final CyclicBarrier barrier = new CyclicBarrier(THREAD_COUNT + 1);
|
||||
|
||||
|
|
|
|||
|
|
@ -147,7 +147,7 @@ public class SimpleLogger extends LegacyAbstractLogger {
|
|||
|
||||
private static final long serialVersionUID = -632788891211436180L;
|
||||
|
||||
private static long START_TIME = System.currentTimeMillis();
|
||||
private static final long START_TIME = System.currentTimeMillis();
|
||||
|
||||
protected static final int LOG_LEVEL_TRACE = LocationAwareLogger.TRACE_INT;
|
||||
protected static final int LOG_LEVEL_DEBUG = LocationAwareLogger.DEBUG_INT;
|
||||
|
|
|
|||
|
|
@ -54,7 +54,7 @@ public class SimpleLoggerConfiguration {
|
|||
private static final boolean LEVEL_IN_BRACKETS_DEFAULT = false;
|
||||
boolean levelInBrackets = LEVEL_IN_BRACKETS_DEFAULT;
|
||||
|
||||
private static String LOG_FILE_DEFAULT = "System.err";
|
||||
private static final String LOG_FILE_DEFAULT = "System.err";
|
||||
private String logFile = LOG_FILE_DEFAULT;
|
||||
OutputChoice outputChoice = null;
|
||||
|
||||
|
|
|
|||
|
|
@ -39,10 +39,10 @@ import org.slf4j.LoggerFactory;
|
|||
*/
|
||||
public class MultithereadedExecutionTest {
|
||||
|
||||
private static int THREAD_COUNT = 2;
|
||||
private Thread[] threads = new Thread[THREAD_COUNT];
|
||||
private static final int THREAD_COUNT = 2;
|
||||
private final Thread[] threads = new Thread[THREAD_COUNT];
|
||||
|
||||
private static long TEST_DURATION_IN_MILLIS = 100;
|
||||
private static final long TEST_DURATION_IN_MILLIS = 100;
|
||||
|
||||
private final PrintStream oldOut = System.out;
|
||||
StateCheckingPrintStream scps = new StateCheckingPrintStream(oldOut);
|
||||
|
|
|
|||
|
|
@ -339,10 +339,10 @@
|
|||
|
||||
<h3>February 19th, 2019 - Release of SLF4J 1.8.0-beta4</h3>
|
||||
|
||||
<p class="highlight"t>In the 1.8.x series, SLF4J has been
|
||||
<p class="highlight">In the 1.8.x series, SLF4J has been
|
||||
modularized per <a
|
||||
href="http://openjdk.java.net/projects/jigsaw/spec/">JPMS/Jigsaw</a>
|
||||
specificaton. The resulting internal changes are <a class="big
|
||||
specification. The resulting internal changes are <a class="big
|
||||
bold" href="faq.html#changesInVersion18">detailed</a> in the FAQ
|
||||
page. </p>
|
||||
|
||||
|
|
@ -353,7 +353,7 @@
|
|||
|
||||
<p>In the 1.8.x series, SLF4J has been modularized
|
||||
per <a href="http://openjdk.java.net/projects/jigsaw/spec/">JPMS/Jigsaw</a>
|
||||
specificaton. The resulting internal changes are <a class="big
|
||||
specification. The resulting internal changes are <a class="big
|
||||
bold" href="faq.html#changesInVersion18">detailed</a> in the FAQ
|
||||
page. Moreover, SLF4J now requires Java 6 or later as
|
||||
slf4j-api now relies on
|
||||
|
|
|
|||
Loading…
Reference in New Issue