All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.clumd.projects.java_custom_logging.logging.ExtendedLoggerProvider Maven / Gradle / Ivy

Go to download

A custom implementation of the SLF4J interface, but with bonuses for using it directly

The newest version!
package com.clumd.projects.java_custom_logging.logging;

import org.slf4j.ILoggerFactory;
import org.slf4j.IMarkerFactory;
import org.slf4j.helpers.BasicMarkerFactory;
import org.slf4j.helpers.NOPMDCAdapter;
import org.slf4j.spi.MDCAdapter;
import org.slf4j.spi.SLF4JServiceProvider;

/**
 * Basically directly copied from {@code org.slf4j.simple.SimpleServiceProvider} but for my {@link ExtendedLogger}s
 */
public class ExtendedLoggerProvider implements SLF4JServiceProvider {

    // to avoid constant folding by the compiler, this field must *not* be final
    @SuppressWarnings("java:S1444")
    public static String requestedApiVersion = "2.0.99"; // !final

    private ILoggerFactory loggerFactory;
    private IMarkerFactory markerFactory;
    private MDCAdapter mdcAdapter;

    @Override
    public ILoggerFactory getLoggerFactory() {
        return loggerFactory;
    }

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

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

    @Override
    public String getRequestedApiVersion() {
        return requestedApiVersion;
    }

    @Override
    public void initialize() {
        loggerFactory = new ExtendedLoggerFactory();
        markerFactory = new BasicMarkerFactory();
        mdcAdapter = new NOPMDCAdapter();
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy