001package org.slf4j.simple;
002
003import org.slf4j.ILoggerFactory;
004import org.slf4j.IMarkerFactory;
005import org.slf4j.helpers.BasicMarkerFactory;
006import org.slf4j.helpers.NOPMDCAdapter;
007import org.slf4j.spi.MDCAdapter;
008import org.slf4j.spi.SLF4JServiceProvider;
009
010public class SimpleServiceProvider implements SLF4JServiceProvider {
011
012    /**
013     * Declare the version of the SLF4J API this implementation is compiled against. 
014     * The value of this field is modified with each major release. 
015     */
016    // to avoid constant folding by the compiler, this field must *not* be final
017    public static String REQUESTED_API_VERSION = "2.0.99"; // !final
018
019    private ILoggerFactory loggerFactory;
020    // LoggerFactory expects providers to initialize markerFactory as early as possible.
021    private final IMarkerFactory  markerFactory;
022    // LoggerFactory expects providers to initialize their MDCAdapter field
023    // as early as possible, preferably at construction time.
024    private final MDCAdapter mdcAdapter;
025
026    public SimpleServiceProvider() {
027        markerFactory = new BasicMarkerFactory();
028        mdcAdapter =  new NOPMDCAdapter();
029    }
030
031    public ILoggerFactory getLoggerFactory() {
032        return loggerFactory;
033    }
034
035    @Override
036    public IMarkerFactory getMarkerFactory() {
037        return markerFactory;
038    }
039
040    @Override
041    public MDCAdapter getMDCAdapter() {
042        return mdcAdapter;
043    }
044
045    @Override
046    public String getRequestedApiVersion() {
047        return REQUESTED_API_VERSION;
048    }
049
050    @Override
051    public void initialize() {
052        loggerFactory = new SimpleLoggerFactory();
053
054    }
055
056}