package ch.polgrabia.utils;

import org.slf4j.ILoggerFactory;
import org.slf4j.IMarkerFactory;
import org.slf4j.spi.MDCAdapter;
import org.slf4j.spi.SLF4JServiceProvider;

import java.util.Properties;

public class AnsiTermLoggerServiceProvider implements SLF4JServiceProvider {
    private static AnsiTermLoggerServiceProvider instance;
    private Properties properties = System.getProperties();

    public static void setInstance(AnsiTermLoggerServiceProvider instance) {
        AnsiTermLoggerServiceProvider.instance = instance;
    }

    public static AnsiTermLoggerServiceProvider getInstance() {
        return instance;
    }

    public void loadProperties(Properties properties) {
        this.properties.putAll(properties);
    }

    @Override
    public ILoggerFactory getLoggerFactory() {
        return new AnsiTermLoggerFactory(properties);
    }

    @Override
    public IMarkerFactory getMarkerFactory() {
        return null;
    }

    @Override
    public MDCAdapter getMDCAdapter() {
        return null;
    }

    @Override
    public String getRequestedApiVersion() {
        return "2.0.7";
    }

    @Override
    public void initialize() {
        AnsiTermLoggerServiceProvider.setInstance(this);
    }
}
